home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2 - Developers' Solutions / Delphi 2 Developers' Solutions.iso / dds / chap03 / howto03 / drwsutl3.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-03-06  |  100.1 KB  |  2,642 lines

  1. unit Drwsutl3;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, ShellAPI, FileCtrl, DRWSUtl1;
  8.  
  9. const
  10.   EOC_CHANGEDIR = 1;  { Error Operation Code for change directory failure }
  11.   EOC_SOURCECOPY = 2; { Error Operation Code for source copy failure      }
  12.   EOC_DESTCOPY = 3;   { Error Operation Code for destination copy failure }
  13.   EOC_DELETEFILE = 4; { Error Operation Code for file delete failure      }
  14.   EOC_DELETEDIR = 5;  { Error Operation Code for directory delete failure }
  15.   EOC_RENAMEFILE = 6; { Error Operation Code for renaming failure         }
  16.   EOC_MAKEDIR = 7;    { Error Operation Code for MkDir failure            }
  17.   EOC_SETATTR = 8;    { Error Operation Code for Set Attributes failure   }
  18.  
  19.   FAC_COPY = 1;       { File Action Code for recursive copying            }
  20.   FAC_MOVE = 2;       { File Action Code for recursive moving             }
  21.   FAC_DELETE = 3;     { File Action Code for recursive deletion           }
  22. type
  23.   { This is a descendant of TFileListbox }
  24.   { Which puts icons of files into the   }
  25.   { Objects array rather than the stand- }
  26.   { ard bitmaps.                         }
  27.   TIconFileListBox = class( TFileListBox )
  28.   public
  29.     { public methods and data }
  30.     procedure ReadFileNames; override;
  31.     function GetNextSelection( SourceDirectory : String;
  32.               var CurrentItem : Integer ) : String;
  33.     constructor Create(AOwner : TComponent); override; { override create    }
  34.     procedure TheDblClick( Sender : TObject );{ This holds override dblclick }
  35.   end;
  36.   TFileWorkBench = class( TComponent )
  37.   public
  38.     GlobalError        : Integer;  { This is used by FMXUCopyFile for er code }
  39.     GlobalErrorType    : Integer;  { This holds the Operation code            }
  40.     function ForceTrailingBackSlash( const TheFileName : String ) : String;
  41.     function StripNonRootTrailingBackSlash(
  42.               const TheFileName : String ) : String;
  43.     procedure GetFileAttributes( TheFile : String; var IsDirectory , IsArchive ,
  44.                 IsVolumeID , IsHidden , IsReadOnly , IsSysFile : Boolean );
  45.     procedure HandleIOException( TheOpCode : Integer; ThePath : String;
  46.                                  TheMessage : String; TheCode : Integer );
  47.     procedure HandleDOSError( TheOpCode : Integer; ThePath : String;
  48.                 TheCode : Integer );
  49.     function CopyFile( TargetPath ,
  50.                DestinationPath : String ) : Boolean;
  51.     procedure ChangeTheDirectory( NewPath : String );
  52.     procedure ChangeTheDriveAndDirectory( NewDrive : Integer );
  53.     procedure CopyTheFile( OldPath , NewPath : String );
  54.     procedure MoveTheFile( OldPath , NewPath : String );
  55.     procedure DeleteTheFile( ThePath : String );
  56.     procedure RenameTheFile( OldPath , NewName : String );
  57.     procedure CreateNewDirectory( NewPath : String );
  58.     procedure RemoveDirectory( ThePath : String );
  59.     procedure SetFileAttributes( TheFile  : String; TheAttributes : Integer );
  60.     procedure RecursivelyCopyDirectory( OldPath , NewPath : String );
  61.     procedure RecursivelyMoveDirectory( OldPath , NewPath : String );
  62.     procedure RecursivelyDeleteDirectory( ThePath : String );
  63.     procedure HandleRecursiveAction( StartingPath , NewPath : String;
  64.                ActionCode : Integer );
  65.   end;
  66.   TFileIconPanel = class( TPanel )
  67.   private
  68.     { Private declarations }
  69.     FHighlightColor : TColor;                 { This holds bright edge bevel }
  70.     FShadowColor    : TColor;                 { This holds dark edge bevel   }
  71.     procedure TheMouseDown(Sender: TObject;
  72.       Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  73.     procedure TheMouseUp(Sender: TObject;
  74.       Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  75.     procedure WMLButtonDblClk(var Message: TWMLButtonDblClk);
  76.      message WM_LBUTTONDBLCLK;
  77.     procedure TheDragOver(Sender, Source: TObject; X,
  78.       Y: Integer; State: TDragState; var Accept: Boolean);
  79.     procedure TheDragDrop(Sender, Source: TObject; X,
  80.       Y: Integer);
  81.   protected                                   { event method procedure.      }
  82.     { Protected declarations }
  83.     procedure Paint; override;                { This allows custom painting  }
  84.   public
  85.     { Public declarations }
  86.     FTheIcon : TIcon;                         { This is the display icon    }
  87.     FTheName : String;                        { This is the filename        }
  88.     FTheLabel : TLabel;                       { This is the display label   }
  89.     Selected : Boolean;                       { This holds selection status }
  90.     constructor Create(AOwner : TComponent); override; { override create    }
  91.     procedure Initialize( PanelX              ,             { Left          }
  92.                           PanelY              ,             { Top           }
  93.                           PanelWidth          ,             { Width         }
  94.                           PanelHeight         ,             { Height        }
  95.                           PanelBevelWidth     ,             { Bevel Width   }
  96.                           LabelFontSize         : Integer;  { Font size     }
  97.                           PanelColor          ,             { Main color    }
  98.                           PanelHighlightColor ,             { Bright color  }
  99.                           PanelShadowColor    ,             { Dark color    }
  100.                           LabelTextColor        : TColor;   { Text color    }
  101.                           TheFilename         ,             { Filename      }
  102.                           LabelFontName         : String;   { Font name     }
  103.                           LabelFontStyle        : TFontStyles;  { Font style}
  104.                           ExtraData             : Integer       );  { Drive }
  105.     destructor Destroy; override;             { override destroy to free    }
  106.   end;
  107.   TFileIconPanelScrollBox = class( TScrollBox )
  108.   public
  109.     { Public methods and data }
  110.     TheFWB              : TFileWorkBench; { Used for file manipulation         }
  111.     IconsNeedRefreshing : Boolean;                   { Flag to redo display    }
  112.     TheIconSize        : Integer;   { Holds Individual Icon size               }
  113.     TheIconSpacing     : Integer;   { Holds total icon footprint               }
  114.     MaxIconsInARow     : Integer;   { Set for screen size.                     }
  115.     TheStoredHandle    : HWnd;
  116.     TheParentForm      : TForm;
  117.     procedure Update;                                { Called to reset display }
  118.     constructor Create( AOwner : TComponent ); override;  { Override inherited }
  119.     procedure ClearTheFIPs;                          { Clears the FIPs safely  }
  120.     procedure AddDriveIcons( var XCounter , YCounter : Integer ); { Add drives }
  121.     procedure GetColorsForFileIcon( TheFile : String;
  122.                var BC , HC , SC , TC : TColor );
  123.     procedure GetIconsForEntireDirectory( TargetPath  : String );
  124.     function GetNextSelection( SourceDirectory : String;
  125.               var CurrentItem : Integer ) : String;
  126.     procedure DisplayRecursiveSearchResults(
  127.       TheStartingDirectory : String );
  128.   end;
  129.   TIOManager = class( TComponent )
  130.   public
  131.     Parent : TForm;
  132.     WhichButton : TMouseButton;
  133.     WhichState  : TShiftState;
  134.     function WasLeftPressed : Boolean;
  135.     function WasRightPressed : Boolean;
  136.     function WasMiddlePressed : Boolean;
  137.     function WasALTPressed : Boolean;
  138.     function WasSHIFTPressed : Boolean;
  139.     function WasCTRLPressed : Boolean;
  140.     procedure OnF1Pressed(Sender: TObject; var Key: Word;
  141.      Shift: TShiftState);
  142.     procedure OnF2Pressed(Sender: TObject; var Key: Word;
  143.      Shift: TShiftState);
  144.     procedure OnF3Pressed(Sender: TObject; var Key: Word;
  145.      Shift: TShiftState);
  146.     procedure OnF4Pressed(Sender: TObject; var Key: Word;
  147.      Shift: TShiftState);
  148.     procedure OnF5Pressed(Sender: TObject; var Key: Word;
  149.      Shift: TShiftState);
  150.     procedure OnF6Pressed(Sender: TObject; var Key: Word;
  151.      Shift: TShiftState);
  152.     procedure OnF7Pressed(Sender: TObject; var Key: Word;
  153.      Shift: TShiftState);
  154.     procedure OnF8Pressed(Sender: TObject; var Key: Word;
  155.      Shift: TShiftState);
  156.     procedure OnF9Pressed(Sender: TObject; var Key: Word;
  157.      Shift: TShiftState);
  158.     procedure OnF10Pressed(Sender: TObject; var Key: Word;
  159.      Shift: TShiftState);
  160.     procedure OnF11Pressed(Sender: TObject; var Key: Word;
  161.      Shift: TShiftState);
  162.     procedure OnF12Pressed(Sender: TObject; var Key: Word;
  163.      Shift: TShiftState);
  164.  end;
  165.   { This procedure gets an icon for a file using FindExecutable  }
  166.   { and ExtractIcon. (assumes file/dir is passed)                }
  167.   procedure GetIconForFile( TheName : String; var TheIcon : TIcon );
  168.   { This procedure spaces out the bitbtn components on a tpanel }
  169.   procedure SpacePanelButtons( WhichPanel : TPanel );
  170.     procedure FMXUCopyFile(const FileName, DestName: String; var GlobalErrorType ,
  171.                GlobalErrorCode : Integer );
  172.  
  173. var TheIOManager : TIOManager;
  174.  
  175. implementation
  176. {$R DRWSUTL3.RES}                 { Import custom resource file }
  177. uses UFMGR12;
  178.  
  179. { It has been edited to return viable error codes!             }
  180. procedure FMXUCopyFile(const FileName, DestName: String; var GlobalErrorType ,
  181.             GlobalErrorCode : Integer );
  182. var
  183.   CopyBuffer: Pointer; { buffer for copying }
  184.   BytesCopied: Longint;
  185.   TheAttr : Integer;
  186.   Source, Dest: Integer; { handles }
  187. const
  188.   ChunkSize: Longint = 8192; { copy in 8K chunks }
  189. begin
  190.   GetMem(CopyBuffer, ChunkSize); { allocate the buffer }
  191.   Source := FileOpen(FileName, fmShareDenyWrite); { open source file }
  192.   if Source < 0 then
  193.   begin  { error creating source file }
  194.     GlobalErrorType := EOC_SOURCECOPY;
  195.     GlobalErrorCode := -IOResult;
  196.     if GlobalErrorCode = 0 then GlobalErrorCode := -157;
  197.     FreeMem( CopyBuffer, ChunkSize );
  198.     exit;
  199.   end;
  200.   Dest := FileCreate(DestName); { create output file; overwrite existing }
  201.   if Dest < 0 then
  202.   begin  { error creating destination file }
  203.     FileClose( Source );
  204.     GlobalErrorType := EOC_DESTCOPY;
  205.     GlobalErrorCode := -IOResult;
  206.     if GlobalErrorCode = 0 then GlobalErrorCode := -159;
  207.     FreeMem( CopyBuffer , ChunkSize );
  208.     exit;
  209.   end;
  210.   {$I-}
  211.   repeat
  212.     BytesCopied := FileRead(Source, CopyBuffer^, ChunkSize); { read chunk}
  213.     if BytesCopied > 0 then { if we read anything... }
  214.     FileWrite(Dest, CopyBuffer^, BytesCopied); { ...write chunk }
  215.   until BytesCopied < ChunkSize; { until we run out of chunks }
  216.   {$I+}
  217.   GlobalErrorCode := -IOResult;  { get any error code which happens during copying }
  218.   FileClose(Dest); { close the destination file }
  219.   FileClose(Source); { close the source file }
  220.   FreeMem(CopyBuffer, ChunkSize); { free the buffer }
  221. end;
  222.  
  223. { This procedure spaces out the bitbtn components on a tpanel }
  224. procedure SpacePanelButtons( WhichPanel : TPanel );
  225. var TheCalculatedSpacing     ,            { Holds primary spacing }
  226.     TheFullCalculatedSpacing   : Integer; { Holds full spacing    }
  227.     Counter_1                  : Integer; { Loop counter          }
  228.     TotalIBs                   : Integer; { Gets total buttons    }
  229. begin
  230.   { Set up spacing values }
  231.   TotalIBs := WhichPanel.ControlCount;
  232.   TheCalculatedSpacing := (( WhichPanel.Width - 6 - ( TotalIbs * 49 ))
  233.    div ( TotalIbs + 1 ));
  234.   TheFullCalculatedSpacing := TheCalculatedSpacing + 49;
  235.   { Loop through all imported buttons and set their Left values }
  236.   for Counter_1 := 1 to WhichPanel.ControlCount do
  237.   begin
  238.     if Counter_1 = 1 then
  239.     begin
  240.       TBitBtn( WhichPanel.Controls[ Counter_1 - 1 ] ).Left := 3 +
  241.        TheCalculatedSpacing;
  242.     end
  243.     else
  244.     begin
  245.       TBitBtn( WhichPanel.Controls[ Counter_1 - 1 ] ).Left := 3 +
  246.        (( Counter_1 - 1 ) * TheFullCalculatedSpacing ) + TheCalculatedSpacing;
  247.     end;
  248.   end;
  249. end;
  250.  
  251. { This procedure gets an icon for a file using FindExecutable  }
  252. { and ExtractIcon. (assumes file/dir is passed)                }
  253. procedure GetIconForFile( TheName : String; var TheIcon : TIcon );
  254. var TheExt           : String; { File extension holder }
  255.     TheOtherPChar  ,           { Windows ASCIIZ string }
  256.     ThePChar         : PChar;  { Windows ASCIIZ string }
  257.     Dummy : Word;
  258. begin
  259.   { Check for directory and if so get directory icon from RES file }
  260.   if (( FileGetAttr( TheName ) and faDirectory ) = faDirectory ) then
  261.   begin
  262.     { Set up the PChar to communicate with Windows }
  263.     GetMem( TheOtherPChar , 255 );
  264.     { Convert Pascal-style string to ASCIIZ Pchar }
  265.     StrPCopy( TheOtherPChar , 'DIRECTORY' );
  266.     { Use API call to return icon handle of Icon Resource in FILECTRL.RES }
  267.     TheIcon.Handle := LoadIcon( hInstance , TheOtherPChar );
  268.     { Release memory from PChar }
  269.     FreeMem( TheOtherPChar , 255 );
  270.     { Leave }
  271.     exit;
  272.   end;
  273.   { Assume archive file; get its extension }
  274.   TheExt := Uppercase( ExtractFileExt( TheName ));
  275.   { If not an executable/image file then use FindExecutable to get icon }
  276.   if (( TheExt <> '.EXE' ) and ( TheExt <> '.BAT' ) and
  277.       ( TheExt <> '.PIF' ) and ( TheExt <> '.COM' )) then
  278.   begin
  279.     { Grab three chunks of memory }
  280.     GetMem( ThePChar , 255 );
  281.     { Set up the name and its directory in Windows string formats }
  282.     StrPCopy( ThePChar, TheName );
  283.     Dummy := 65535;
  284.     {**** Windows 95 Specialized call ****** }
  285.     TheIcon.Handle := ExtractAssociatedIcon( hInstance , ThePChar , Dummy );
  286.     if TheIcon.Handle = 0 then
  287.     begin
  288.       GetMem( TheOtherPChar , 255 );
  289.       StrPCopy( TheOtherPChar , 'NOICON' );
  290.       TheIcon.Handle := LoadIcon( hInstance , TheOtherPChar );
  291.       FreeMem( TheOtherPChar , 255 );
  292.       exit;
  293.     end;
  294.     FreeMem( ThePChar , 255 );
  295.   end
  296.   else
  297.   { Assume Windows Executable file, so get icon from it with ExtractIcon API }
  298.   begin
  299.     GetMem( ThePChar , 255 );
  300.     StrPCopy( ThePChar , TheName );
  301.     { Try to get first icon for file }
  302.     Dummy := 65535;
  303.     TheIcon.Handle := ExtractAssociatedIcon( hInstance , ThePChar , Dummy );
  304.     FreeMem( ThePChar , 255 );
  305.     { If handle is 0 invalid icon format so use default from RES file }
  306.     if TheIcon.Handle = 0 then
  307.     begin
  308.       GetMem( TheOtherPChar , 255 );
  309.       StrPCopy( TheOtherPChar , 'NOICON' );
  310.       TheIcon.Handle := LoadIcon( hInstance , TheOtherPChar );
  311.       FreeMem( TheOtherPChar , 255 );
  312.       exit;
  313.     end;
  314.   end;
  315. end;
  316.  
  317. { This procedure handles pressing of F1 for CCFileManagerForm }
  318. procedure TIoManager.OnF1Pressed(Sender: TObject; var Key: Word;
  319.   Shift: TShiftState);
  320. begin
  321.   MessageDlg( 'Help not implemented!' , mtInformation,[mbok],0);
  322. end;
  323.  
  324. { This procedure handles pressing of F2 for CCFileManagerForm }
  325. procedure TIoManager.OnF2Pressed(Sender: TObject; var Key: Word;
  326.   Shift: TShiftState);
  327. begin
  328.   TCCFileMgrForm( Parent ).BitBtn1Click( Sender );
  329. end;
  330.  
  331. { This procedure handles pressing of F3 for CCFileManagerForm }
  332. procedure TIoManager.OnF3Pressed(Sender: TObject; var Key: Word;
  333.   Shift: TShiftState);
  334. begin
  335.   TCCFileMgrForm( Parent ).BitBtn2Click( Sender );
  336. end;
  337.  
  338. { This procedure handles pressing of F4 for CCFileManagerForm }
  339. procedure TIoManager.OnF4Pressed(Sender: TObject; var Key: Word;
  340.   Shift: TShiftState);
  341. begin
  342.   TCCFileMgrForm( Parent ).BitBtn3Click( Sender );
  343. end;
  344.  
  345. { This procedure handles pressing of F5 for CCFileManagerForm }
  346. procedure TIoManager.OnF5Pressed(Sender: TObject; var Key: Word;
  347.   Shift: TShiftState);
  348. begin
  349.   TCCFileMgrForm( Parent ).BitBtn4Click( Sender );
  350. end;
  351.  
  352. { This procedure handles pressing of F6 for CCFileManagerForm }
  353. procedure TIoManager.OnF6Pressed(Sender: TObject; var Key: Word;
  354.   Shift: TShiftState);
  355. begin
  356.   TCCFileMgrForm( Parent ).BitBtn5Click( Sender );
  357. end;
  358.  
  359. { This procedure handles pressing of F7 for CCFileManagerForm }
  360. procedure TIoManager.OnF7Pressed(Sender: TObject; var Key: Word;
  361.   Shift: TShiftState);
  362. begin
  363.   TCCFileMgrForm( Parent ).BitBtn9Click( Sender );
  364. end;
  365.  
  366. { This procedure handles pressing of F8 for CCFileManagerForm }
  367. procedure TIoManager.OnF8Pressed(Sender: TObject; var Key: Word;
  368.   Shift: TShiftState);
  369. begin
  370.   TCCFileMgrForm( Parent ).BitBtn6Click( Sender );
  371. end;
  372.  
  373. { This procedure handles pressing of F9 for CCFileManagerForm }
  374. procedure TIoManager.OnF9Pressed(Sender: TObject; var Key: Word;
  375.   Shift: TShiftState);
  376. begin
  377.   TCCFileMgrForm( Parent ).Update;
  378. end;
  379.  
  380. { This procedure handles pressing of F10 for CCFileManagerForm }
  381. procedure TIoManager.OnF10Pressed(Sender: TObject; var Key: Word;
  382.   Shift: TShiftState);
  383. begin
  384.   TCCFileMgrForm( Parent ).BitBtn7Click( Sender );
  385. end;
  386.  
  387. { This procedure handles pressing of F11 for CCFileManagerForm }
  388. procedure TIoManager.OnF11Pressed(Sender: TObject; var Key: Word;
  389.   Shift: TShiftState);
  390. begin
  391.   TCCFileMgrForm( Parent ).BitBtn8Click( Sender );
  392. end;
  393.  
  394. { This procedure handles pressing of F12 for CCFileManagerForm }
  395. procedure TIoManager.OnF12Pressed(Sender: TObject; var Key: Word;
  396.   Shift: TShiftState);
  397. begin
  398.   TCCFileMgrForm( Parent ).BitBtn10Click( Sender );
  399. end;
  400.  
  401. { Returns True if the Left Button was pressed in the last mouse operation }
  402. function TIOManager.WasLeftPressed : Boolean;
  403. begin
  404.   if ( mbLeft = WhichButton ) then WasLeftPressed := true else
  405.    WasLeftPressed := false;
  406. end;
  407.  
  408. { Returns true if the Right Button was pressed in the last mouse operation }
  409. function TIOManager.WasRightPressed : Boolean;
  410. begin
  411.   if mbRight = WhichButton then WasRightPressed := true else
  412.    WasRightPressed := false;
  413. end;
  414.  
  415. { Returns true if the Middle Button was pressed in the last mouse operation }
  416. function TIOManager.WasMiddlePressed : Boolean;
  417. begin
  418.   if mbMiddle = WhichButton then WasMiddlePressed := true else
  419.    WasMiddlePressed := false;
  420. end;
  421.  
  422. { Returns true if the ALT key was down during the last IO operation }
  423. function TIOManager.WasALTPressed : Boolean;
  424. begin
  425.   if ssAlt in WhichState then WasALTPressed := true else
  426.    WasALTPressed := false;
  427. end;
  428.  
  429. { Returns true if either SHIFT key was down during the last IO operation }
  430. function TIOManager.WasSHIFTPressed : Boolean;
  431. begin
  432.   if ssShift in WhichState then WasSHIFTPressed := true else
  433.    WasSHIFTPressed := false;
  434. end;
  435.  
  436. { Returns true if the Control Key was down during the last IO operation }
  437. function TIOManager.WasCTRLPressed : Boolean;
  438. begin
  439.   if ssCtrl in WhichState then WasCTRLPressed := true else
  440.    WasCTRLPressed := false;
  441. end;
  442.  
  443.  
  444. { This procedure does a fully error-trapped change directory }
  445. procedure TFileWorkBench.ChangeTheDirectory( NewPath : String );
  446. var CurrentDirectory : String;
  447. begin
  448.   if NewPath = '..' then
  449.   begin { Back up one level }
  450.     {$I+}
  451.     try
  452.       { Find the current directory }
  453.       GetDir( 0 , CurrentDirectory );
  454.       { Use EFP to move up one level }
  455.       CurrentDirectory := ExtractFilePath( CurrentDirectory );
  456.       { Strip trailing \ if not root }
  457.       CurrentDirectory := StripNonRootTrailingBackSlash( CurrentDirectory );
  458.       { Try the change to the new drive }
  459.       ChDir( CurrentDirectory );
  460.     except
  461.       { if any exception occurs instantiate exception and show }
  462.       On E:EInOutError do
  463.       begin
  464.         { Call custom error display/lookup procedure }
  465.         HandleIOException( EOC_CHANGEDIR , CurrentDirectory ,
  466.          E.Message , E.ErrorCode );
  467.       end;
  468.     end;
  469.   end
  470.   else
  471.   begin { Change to explicit path }
  472.     {$I+}
  473.     try
  474.       { Get target directory path }
  475.       CurrentDirectory := NewPath;
  476.       { Strip trailing \ if not root }
  477.       CurrentDirectory := StripNonRootTrailingBackSlash( CurrentDirectory );
  478.       { Try the change to the new drive }
  479.       ChDir( CurrentDirectory );
  480.     except
  481.       { if any exception occurs instantiate exception and show }
  482.       On E:EInOutError do
  483.       begin
  484.         { Call custom error display/lookup procedure }
  485.         HandleIOException( EOC_CHANGEDIR , CurrentDirectory ,
  486.          E.Message , E.ErrorCode );
  487.       end;
  488.     end;
  489.   end;
  490. end;
  491.  
  492. { This procedure does a fully error-trapped change directory }
  493. procedure TFileWorkBench.ChangeTheDriveAndDirectory( NewDrive : Integer );
  494. var CurrentDirectory : String;
  495. begin
  496.   {$I+}
  497.   try
  498.     { Find the working directory on new drive }
  499.     GetDir( NewDrive , CurrentDirectory );
  500.     { Try the change to the new drive }
  501.     ChDir( CurrentDirectory );
  502.   except
  503.     { if any exception occurs instantiate exception and show }
  504.     On E:EInOutError do
  505.     begin
  506.       { Call custom error display/lookup procedure }
  507.       HandleIOException( EOC_CHANGEDIR , CurrentDirectory ,
  508.        E.Message , E.ErrorCode );
  509.     end;
  510.   end;
  511. end;
  512.  
  513. { This procedure copies a single file with error trapping }
  514. procedure TFileWorkBench.CopyTheFile( OldPath , NewPath : String );
  515. var AResult : Boolean; { Internal data flag }
  516. begin
  517.   { If Copyfile returns false an error occurred }
  518.   AResult := CopyFile( OldPath , NewPath +
  519.    ExtractFileName( OldPath ));
  520.   { Display meaningful error message }
  521.   if not AResult then HandleDOSError( GlobalErrorType , OldPath, GlobalError );
  522. end;
  523.  
  524. { This procedure moves a file by copying and delete it }
  525. procedure TFileWorkBench.MoveTheFile( OldPath , NewPath : String );
  526. var AResult : Boolean; { Internal data flag }
  527.     TheFile : File;    { Use to get errors  }
  528. begin
  529.   { If Copyfile returns false an error occurred }
  530.   AResult := CopyFile( OldPath , NewPath +
  531.     ExtractFileName( OldPath ));
  532.   { Display meaningful error message }
  533.   if not AResult then HandleDOSError( GlobalErrorType ,
  534.     OldPath , GlobalError );
  535.   { After valid copying, delete source file }
  536.   {$I+}
  537.   if AResult then try
  538.     { Use this trick to get valid exception handling }
  539.     AssignFile( TheFile , OldPath );
  540.     { Use erase because Deletefile doesn't give exceptions! }
  541.     Erase( TheFile );
  542.   except
  543.     { if any exception occurs instantiate exception and show }
  544.     On E:EInOutError do
  545.     begin
  546.       { Call custom error display/lookup procedure }
  547.       HandleIOException( EOC_DELETEFILE , OldPath ,
  548.        E.Message , E.ErrorCode );
  549.     end;
  550.   end;
  551. end;
  552.  
  553. { This procedure safely deletes a single file }
  554. procedure TFileWorkBench.DeleteTheFile( ThePath : String );
  555. var TheFile : File; { Internal file handle }
  556. begin
  557.   {$I+}
  558.   try
  559.     { Use this trick to get valid exception handling }
  560.     AssignFile( TheFile , ThePath );
  561.     { Use erase because Deletefile doesn't give exceptions! }
  562.     Erase( TheFile );
  563.   except
  564.     { if any exception occurs instantiate exception and show }
  565.     On E:EInOutError do
  566.     begin
  567.       { Call custom error display/lookup procedure }
  568.       HandleIOException( EOC_DELETEFILE , ThePath ,
  569.        E.Message , E.ErrorCode );
  570.     end;
  571.   end;
  572. end;
  573.  
  574. { This procedure renames a file with full error trapping }
  575. procedure TFileWorkBench.RenameTheFile( OldPath , NewName : String );
  576. var TheFile : File; { Internal file handle }
  577. begin
  578.   {$I+}
  579.   try
  580.     { Use this trick to get valid exception handling }
  581.     AssignFile( TheFile , OldPath );
  582.     { Use this because RenameFile doesn't give exceptions! }
  583.     Rename( TheFile , NewName );
  584.   except
  585.     { if any exception occurs instantiate exception and show }
  586.     On E:EInOutError do
  587.     begin
  588.       { Call custom error display/lookup procedure }
  589.       HandleIOException( EOC_RENAMEFILE , OldPath  ,
  590.        E.Message , E.ErrorCode );
  591.     end;
  592.   end;
  593. end;
  594.  
  595. { This procedure creates a new directory with full error trapping }
  596. procedure TFileWorkBench.CreateNewDirectory( NewPath : String );
  597. begin
  598.   {$I+}
  599.   try
  600.     Mkdir( NewPath );
  601.   except
  602.     { if any exception occurs instantiate exception and show }
  603.     On E:EInOutError do
  604.     begin
  605.       { Call custom error display/lookup procedure }
  606.       HandleIOException( EOC_MAKEDIR , NewPath  ,
  607.        E.Message , E.ErrorCode );
  608.     end;
  609.   end;
  610. end;
  611.  
  612. { This procedure remove a directory with full error trapping }
  613. procedure TFileWorkBench.RemoveDirectory( ThePath : String );
  614. begin
  615.   {$I+}
  616.   try
  617.     Rmdir( ThePath );
  618.   except
  619.     { if any exception occurs instantiate exception and show }
  620.     On E:EInOutError do
  621.     begin
  622.       { Call custom error display/lookup procedure }
  623.       HandleIOException( EOC_DELETEDIR , ThePath  ,
  624.        E.Message , E.ErrorCode );
  625.     end;
  626.   end;
  627. end;
  628.  
  629. { Use this to set the attributes of a file with error trapping }
  630. procedure TFileWorkBench.SetFileAttributes( TheFile  : String;
  631.            TheAttributes : Integer );
  632. var TheResult : Integer; { Holds error code if any }
  633. begin
  634.   { Attempt to set the attributes }
  635.   TheResult := FileSetAttr( TheFile , TheAttributes );
  636.   { if negative number error, so signal }
  637.   if TheResult < 0 then
  638.    HandleDOSError( EOC_SETATTR , TheFile , -TheResult );
  639. end;
  640.  
  641. { This procedure recursively copies a directory to a new path }
  642. procedure TFileWorkBench.RecursivelyCopyDirectory( OldPath , NewPath : String );
  643. var TheDir : String; { Holds source directory }
  644. begin
  645.   { Get the source directory to copy }
  646.   TheDir := ExtractFileName( OldPath );
  647.   { Force a backslash to the newpath variable }
  648.   NewPath := ForceTrailingBackSlash( NewPath );
  649.   { Add the source directory to the target path }
  650.   NewPath := NewPath + TheDir;
  651.   { Create a new directory with the new name }
  652.   CreateNewDirectory( NewPath );
  653.   { Force a backslash for compatibility }
  654.   NewPath := FOrcetrailingBackSlash( NewPath );
  655.   { Do the recursive call }
  656.   HandleRecursiveAction( OldPath , NewPath , FAC_COPY );
  657. end;
  658.  
  659. { This procedure recursively moves a directory tree }
  660. procedure TFileWorkBench.RecursivelyMoveDirectory( OldPath , NewPath : String );
  661. var TheDir    : String; { Holds source directory  }
  662.     SavedPath : String; { Holds saved dir to kill }
  663. begin
  664.   { Get the source directory to move }
  665.   TheDir := ExtractFileName( OldPath );
  666.   { Force a backslash to the newpath variable }
  667.   NewPath := ForceTrailingBackSlash( NewPath );
  668.   { Save the starting path just in case }
  669.   SavedPath := OldPath;
  670.   { Add the source directory to the target path }
  671.   NewPath := NewPath + TheDir;
  672.   { Create a new directory with the new name }
  673.   CreateNewDirectory( NewPath );
  674.   { Force a backslash for compatibility }
  675.   NewPath := FOrcetrailingBackSlash( NewPath );
  676.   { Do the recursive call }
  677.   HandleRecursiveAction( OldPath , NewPath , FAC_MOVE );
  678.   { Remove the source directory }
  679.   RemoveDirectory( SavedPath );
  680. end;
  681.  
  682. { This procedure handles recursively deleting an entire directory tree }
  683. procedure TFileWorkBench.RecursivelyDeleteDirectory( ThePath : String );
  684. begin
  685.   HandleRecursiveAction( ThePath , '' , FAC_DELETE );
  686. end;
  687.  
  688.  
  689. { This is the generic routine to copy, move, and delete whole directory trees }
  690. procedure TFileWorkBench.HandleRecursiveAction( StartingPath , NewPath : String;
  691.            ActionCode : Integer );
  692. { VITAL!!! These variables MUST be local for recursrion to work! }
  693. var
  694.     Finished        : Boolean;         { Loop flag              }
  695.     TheSR           : TSearchRec;      { Searchrecord for FF/FN }
  696.     TheResult       : Integer;         { return variable        }
  697.     TargetPath ,
  698.     FileMask   ,
  699.     TheWorkingDirectory ,
  700.     TheStoredWorkingDirectory ,
  701.     ModifiedDirectory  : String;       { path for FF/FN         }
  702.     TheFIP          : TFileIconPanel;  { generic FIP holder     }
  703.     ButtonColor   ,                    { main panel color       }
  704.     ButtonHLColor ,                    { bright panel color     }
  705.     ButtonSColor  ,                    { dark panel color       }
  706.     Textcolor       : TColor;          { label text color       }
  707.     TheFile         : File;
  708.  
  709. begin
  710.   { Set up the initial variables }
  711.   Finished := false;
  712.   TheWorkingDirectory := StartingPath;
  713.   TheStoredWorkingDirectory := TheWorkingDirectory;
  714.   TheWorkingDirectory := TheWorkingDirectory + '\*.*';
  715.   TargetPath := ExtractFilePath( TheWorkingDirectory );
  716.   { Make the call to FindFirst set to get any file }
  717.   TheResult := FindFirst( TheWorkingDirectory , faAnyFile , TheSR );
  718.   { loop through all files in the directory and delete them }
  719.   while not Finished do
  720.   begin
  721.     { Make call to FindNext, using only SearchRecord from FindFirst }
  722.     TheResult := FindNext( TheSR );
  723.     { A -1 result means no more files so exit }
  724.     if TheResult <> 0 then finished := true else
  725.     begin
  726.       if (( FileGetAttr( TargetPath + TheSR.Name ) and faDirectory )
  727.        <> faDirectory ) then
  728.       begin { A File }
  729.         case ActionCode of
  730.           FAC_COPY :
  731.               begin
  732.                 CopyTheFile( TargetPath + TheSR.Name , NewPath );
  733.               end;
  734.           FAC_MOVE :
  735.               begin
  736.                 MoveTheFile( TargetPath + TheSR.Name , NewPath );
  737.               end;
  738.           FAC_DELETE :
  739.               begin { Delete }
  740.                 if MessageDlg( 'Delete file ' + TargetPath + TheSR.Name + '?',
  741.                    mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  742.                     DeleteTheFile( TargetPath + TheSR.Name );
  743.               end;
  744.         end;
  745.       end;
  746.     end;
  747.   end;
  748.   { Set up the variables to do recursive calls on all directories}
  749.   Finished := false;
  750.   ModifiedDirectory := TheStoredWorkingdirectory + '\*.*';
  751.   { Make the call to FindFirst set to get any file, ignore result }
  752.   TheResult := FindFirst( ModifiedDirectory , faDirectory , TheSR );
  753.   while not Finished do
  754.   begin
  755.     { Make call to FindNext, using only SearchRecord from FindFirst }
  756.     TheResult := FindNext( TheSR );
  757.     { A -1 result means no more files so exit }
  758.     if TheResult <> 0 then
  759.       finished := true
  760.     else
  761.     begin
  762.       if TheSR.Name <> '..' then { Ignore backup in this case }
  763.       begin
  764.         if (( FileGetAttr( TargetPath + TheSR.Name ) and faDirectory )
  765.          = faDirectory ) then
  766.         begin
  767.           { Send in the new directory name }
  768.           ModifiedDirectory := TheStoredWorkingDirectory  + '\' +
  769.            TheSR.Name;
  770.           { Reproduce directory structure for recursion in copy/move }
  771.           NewPath := NewPath + TheSR.Name;
  772.           case ActionCode of
  773.             FAC_COPY , FAC_MOVE :
  774.                begin { Create ahead for move and copy }
  775.                  { Make the new directory for moving and copying }
  776.                  CreateNewDirectory( NewPath );
  777.                  { Force a backslash for compatibility }
  778.                  NewPath := ForceTrailingBackSlash( NewPath );
  779.                end;
  780.             FAC_DELETE :
  781.                begin  { No prior action needed for Delete }
  782.                end;
  783.           end;
  784.           { Do the recursive call }
  785.           HandleRecursiveAction( ModifiedDirectory , NewPath , ActionCode );
  786.           case ActionCode of
  787.             FAC_COPY :
  788.                begin { no action for copy }
  789.                end;
  790.             FAC_MOVE , FAC_DELETE :
  791.                begin  { Delete }
  792.                  { Get a confirmation }
  793.                  if MessageDlg( 'Remove Directory ' + TargetPath + TheSR.Name
  794.                   + '?', mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  795.                    RemoveDirectory( TargetPath + TheSR.Name );
  796.                end;
  797.           end;
  798.         end;
  799.       end;
  800.     end;
  801.   end;
  802. end;
  803.  
  804. { This is a generic copy routine taken from Delphi sample code }
  805. { This function calls the sample Copy code and handles errors }
  806. function TFileWorkBench.CopyFile( TargetPath ,
  807.           DestinationPath : String ) : Boolean;
  808. begin
  809.   { Set global error value to no error }
  810.   GlobalError := 0;
  811.   { Call the sample procedure to do the copy }
  812.   FMXUCopyFile( TargetPath, DestinationPath , GlobalErrorType , GlobalError );
  813.   { If no error return true else return false }
  814.   if GlobalError < 0 then CopyFile := false else
  815.    CopyFile := true;
  816. end;
  817.  
  818. { This procedure handles displaying a user-friendly Dialog box with a }
  819. { Message for Delphi IO exception errors.                             }
  820. procedure TFileWorkBench.HandleIOException( TheOpCode : Integer;
  821.            ThePath : String; TheMessage : String; TheCode : Integer );
  822. var ErrorMessageString : String;  { Holds internal data }
  823.     OperationString    : String;  { Holds internal data }
  824. begin
  825.   { clear to check for unrecognized code }
  826.   ErrorMessageString := '';
  827.   { Check against imported code }
  828.   case TheCode of
  829.     2    : ErrorMessageString := 'File not found';
  830.     3    : ErrorMessageString := 'Path not found';
  831.     4    : ErrorMessageString := 'Too many open files';
  832.     5    : ErrorMessageString := 'File access denied';
  833.     6    : ErrorMessageString := 'Invalid file handle';
  834.     12    : ErrorMessageString := 'Invalid file access code';
  835.     15    : ErrorMessageString := 'Invalid drive number';
  836.     16  : ErrorMessageString := 'Cannot remove current directory';
  837.     17    : ErrorMessageString := 'Cannot rename across drives';
  838.     100    : ErrorMessageString := 'Disk read error';
  839.     101    : ErrorMessageString := 'Disk write error';
  840.     102    : ErrorMessageString := 'File not assigned';
  841.     103    : ErrorMessageString := 'File not open';
  842.     104    : ErrorMessageString := 'File not open for input';
  843.     105    : ErrorMessageString := 'File not open for output';
  844.   end;
  845.   case TheOpCode of
  846.     EOC_CHANGEDIR : OperationString := 'Unable to Change Directory due to ';
  847.     EOC_SOURCECOPY : OperationString := 'Unable to Copy due to Source File ';
  848.     EOC_DESTCOPY : OperationString := 'Unable to Copy due to Destination File ';
  849.     EOC_DELETEFILE : OperationString := 'Unable to Delete File due to ';
  850.     EOC_DELETEDIR : OperationString := 'Unable to Delete Directory due to ';
  851.     EOC_RENAMEFILE : OperationString := 'Unable to Rename File due to ';
  852.     EOC_MAKEDIR : OperationString := 'Unable to Create New Directory due to ';
  853.     EOC_SETATTR : OperationString := 'Unable to Set File Attributes due to ';
  854.   end;
  855.   { If not recognized use message; not a DOS error; reset cursor for neatness }
  856.   if ErrorMessageString = '' then
  857.   begin
  858.     Screen.Cursor := crDefault;
  859.     MessageDlg( OperationString + ExtractFileName( ThePath ) + ' ' +
  860.      TheMessage , mtError , [mbOK],0);
  861.   end
  862.   else
  863.   begin
  864.     { Recognized DOS exception, reset cursor for neatness }
  865.     Screen.Cursor := crDefault;
  866.     MessageDlg( OperationString + ExtractFileName( ThePath ) + ' ' +
  867.      ErrorMessageString , mtError , [mbOK], 0 );
  868.   end;
  869. end;
  870.  
  871. { This procedure handles displaying a user-friendly Dialog box with a }
  872. { Message for DOS error codes.                                        }
  873. procedure TFileWorkBench.HandleDOSError( TheOpCode : Integer;
  874.            ThePath : String;  TheCode : Integer );
  875. var ErrorMessageString : String;  { internal message holder }
  876.     OperationString : String;     { internal message holder }
  877. begin
  878.   { clear the message holder to check for unrecognized code }
  879.   ErrorMessageString := '';
  880.   { Negate the code back to normal number and check to set string }
  881.   case -TheCode of
  882.     2    : ErrorMessageString := 'File not found';
  883.     3    : ErrorMessageString := 'Path not found';
  884.     4    : ErrorMessageString := 'Too many open files';
  885.     5    : ErrorMessageString := 'File access denied';
  886.     6    : ErrorMessageString := 'Invalid file handle';
  887.     12    : ErrorMessageString := 'Invalid file access code';
  888.     15    : ErrorMessageString := 'Invalid drive number';
  889.     16  : ErrorMessageString := 'Cannot remove current directory';
  890.     17    : ErrorMessageString := 'Cannot rename across drives';
  891.     100    : ErrorMessageString := 'Disk read error';
  892.     101    : ErrorMessageString := 'Disk write error';
  893.     102    : ErrorMessageString := 'File not assigned';
  894.     103    : ErrorMessageString := 'File not open';
  895.     104    : ErrorMessageString := 'File not open for input';
  896.     105    : ErrorMessageString := 'File not open for output';
  897.     157 : ErrormessageString := 'Could not open Source File';
  898.     159 : ErrormessageString := 'Could not open Target File';
  899.   end;
  900.   case TheOpCode of
  901.     EOC_CHANGEDIR : OperationString := 'Unable to Change Directory due to ';
  902.     EOC_SOURCECOPY : OperationString := 'Unable to Copy due to Source File ';
  903.     EOC_DESTCOPY : OperationString := 'Unable to Copy due to Destination File ';
  904.     EOC_DELETEFILE : OperationString := 'Unable to Delete File due to ';
  905.     EOC_DELETEDIR : OperationString := 'Unable to Delete Directory due to ';
  906.     EOC_RENAMEFILE : OperationString := 'Unable to Rename File due to ';
  907.     EOC_MAKEDIR : OperationString := 'Unable to Create New Directory due to ';
  908.     EOC_SETATTR : OperationString := 'Unable to Set File Attributes due to ';
  909.   end;
  910.   { If the string is empty an unrecognized code was sent in }
  911.   if ErrorMessageString = '' then
  912.   begin
  913.     { Sent up db based on source or target error; reset cursor for neatness }
  914.     Screen.Cursor := crDefault;
  915.     MessageDlg( OperationString + ExtractFileName( ThePath ) + ' Error Code: ' +
  916.      IntToStr( TheCode ) , mtError , [mbOK],0);
  917.   end
  918.   else  { Code is recognized, use message from case statement }
  919.   begin
  920.     { Format the output for source or target error }
  921.     Screen.Cursor := crDefault;
  922.     MessageDlg( OperationString + ExtractFileName( ThePath ) + ' ' +
  923.      ErrorMessageString , mtError , [mbOK], 0 );
  924.   end;
  925. end;
  926.  
  927. { This procedure sets the imported booleans to the file's attributes }
  928. procedure TFileWorkBench.GetFileAttributes( TheFile : String; var IsDirectory ,
  929.            IsArchive , IsVolumeID , IsHidden , IsReadOnly ,
  930.             IsSysFile : Boolean );
  931. var TheResult : Integer; { Traps for error code on VolumeID }
  932. begin
  933.   { Clear the imported flags for default }
  934.   IsDirectory := false;
  935.   IsArchive := false;
  936.   IsVolumeID := false;
  937.   IsHidden := False;
  938.   IsReadOnly := false;
  939.   IsSysFile := false;
  940.   { Make the Dos call }
  941.   TheResult := FileGetAttr( TheFile );
  942.   if TheResult < 0 then
  943.   begin
  944.     { Volume ID returns -2 (?) }
  945.     IsVolumeID := true;
  946.     { It has no other properties }
  947.     exit;
  948.   end;
  949.   { Use AND test to set all other properties }
  950.   if (( TheResult and faDirectory ) = faDirectory ) then IsDirectory := true;
  951.   if (( TheResult and faArchive ) = faArchive ) then IsArchive := true;
  952.   if (( TheResult and faVolumeID ) = faVolumeID ) then IsVolumeID := true;
  953.   if (( TheResult and faReadOnly ) = faReadOnly ) then IsReadOnly := true;
  954.   if (( TheResult and faHidden ) = faHidden ) then IsHidden := true;
  955.   if (( TheResult and faSysFile ) = faSysFile ) then IsSysFile := true;
  956. end;
  957.  
  958. { This function makes sure a pathname has a trailing \ }
  959. function TFileWorkBench.ForceTrailingBackSlash(
  960.           const TheFileName : String ) : String;
  961. var TempString : String;  { Used to hold function result }
  962. begin
  963.   { If no trailing \ add one (root will already have one.) }
  964.   if TheFileName[ Length( TheFileName ) ] <> '\' then
  965.    TempString := TheFileName + '\' else TempString := TheFileName;
  966.   { Return modified or non-modified string }
  967.   ForceTrailingBackslash := TempString;
  968. end;
  969.  
  970. { This function makes sure a non-root dir has no trailing \ }
  971. function TFileWorkBench.StripNonRootTrailingBackSlash(
  972.           const TheFileName : String ) : String;
  973. var TempString : String ; { Used to hold function result }
  974. begin
  975.   { Default is no change }
  976.   TempString := TheFileName;
  977.   { If not root then }
  978.   if Length( TheFileName ) > 3 then
  979.   begin
  980.     { If has a trailing backslash remove it }
  981.     if TheFileName[ Length( TheFileName )] = '\' then
  982.     begin
  983.       TempString := Copy( TheFileName , 1 ,
  984.        Length( TheFileName ) - 1 );
  985.     end;
  986.   end;
  987.   { Export the final result }
  988.   StripNonRootTrailingBackSlash := TempString;
  989. end;
  990.  
  991. { This gets the next selected listbox item }
  992. function TIconFileListBox.GetNextSelection( SourceDirectory : String;
  993.           var CurrentItem : Integer ): String;
  994. var TheResult : String;  { Internal storage }
  995.     finished  : boolean; { Loop flag        }
  996. begin
  997.   { If out of items to check signal and exit }
  998.   if CurrentItem > Items.Count then TheResult := '' else
  999.   begin
  1000.     { Otherwise scan from current position till match or end }
  1001.     finished := false;
  1002.     while not finished do
  1003.     begin
  1004.       { Check against selected property }
  1005.       if Selected[ CurrentItem - 1 ] then
  1006.       begin
  1007.         { If selected then return it and abort loop }
  1008.         TheResult := SourceDirectory + Items[ CurrentItem - 1 ];
  1009.         finished := true;
  1010.         { Increment current position }
  1011.         CurrentItem := CurrentItem + 1;
  1012.      end
  1013.       else
  1014.       begin
  1015.         { Increment current position }
  1016.         CurrentItem := CurrentItem + 1;
  1017.         { Otherwise check for end of data and abort if out of entries }
  1018.         if CurrentItem > Items.Count then
  1019.         begin
  1020.           TheResult := '';
  1021.           finished := true;
  1022.         end;
  1023.       end;
  1024.     end;
  1025.   end;
  1026.   { Return stored result }
  1027.   GetNextSelection := TheResult;
  1028. end;
  1029.  
  1030. { Modified from VCL Source Copyright 1995 }
  1031. { Borland International, Inc.             }
  1032. { Use this to override display with icons }
  1033. procedure TIconFileListBox.ReadFileNames;
  1034. var
  1035.   AttrIndex   : TFileAttr;
  1036.   i           : Integer;
  1037.   FileExt     : string;
  1038.   MaskPtr     : PChar;
  1039.   Ptr         : PChar;
  1040.   AttrWord    : Word;
  1041.   TempPicture : TPicture;
  1042.   TempBmp     : TBitmap;
  1043.   TempIcon    : TIcon;
  1044. const
  1045.   Attributes: array[TFileAttr] of Word =
  1046.   ( DDL_READONLY , DDL_HIDDEN , DDL_SYSTEM , $0008 , DDL_DIRECTORY ,
  1047.     DDL_ARCHIVE  , DDL_EXCLUSIVE );
  1048. begin
  1049.   { if no handle allocated yet, this call will force         }
  1050.   { one to be allocated incorrectly (i.e. at the wrong time. }
  1051.   { In due time, one will be allocated appropriately.        }
  1052.   AttrWord := DDL_READWRITE;
  1053.   if HandleAllocated then
  1054.   begin
  1055.     { Set attribute flags based on values in FileType }
  1056.     for AttrIndex := ftReadOnly to ftArchive do
  1057.      if AttrIndex in FileType then
  1058.       AttrWord := AttrWord or Attributes[ AttrIndex ];
  1059.  
  1060.     { Use Exclusive bit to exclude normal files }
  1061.     if not ( ftNormal in FileType ) then
  1062.       AttrWord := AttrWord or DDL_EXCLUSIVE;
  1063.  
  1064.     ChDir( FDirectory ); { go to the directory we want }
  1065.     Clear;               { clear the list }
  1066.  
  1067.     GetMem( MaskPtr , 256 );
  1068.     StrPCopy( MaskPtr , FMask );
  1069.     while MaskPtr <> nil do
  1070.     begin
  1071.       Ptr := StrScan ( MaskPtr , ';' );
  1072.       if Ptr <> nil then  Ptr^ := #0;
  1073.       { build the list }
  1074.       SendMessage( Handle , LB_DIR , AttrWord , Longint( MaskPtr ));
  1075.       if Ptr <> nil then
  1076.       begin
  1077.         Ptr^ := ';';
  1078.         Inc ( Ptr );
  1079.       end;
  1080.       MaskPtr := Ptr;
  1081.     end;
  1082.     FreeMem( MaskPtr , 256 );
  1083.     { Now add the bitmaps }
  1084.     {---------------------------- begin custom code --------------------------}
  1085.     { Create the TPicture for exchange purposes }
  1086.     TempPicture := TPicture.Create;
  1087.     { Set it to icon widths }
  1088.     TempPicture.Bitmap.Width := 32;
  1089.     TempPicture.Bitmap.Height := 32;
  1090.     { Run down the list }
  1091.     for i := 0 to Items.Count - 1 do
  1092.     begin
  1093.       { Create a new temporary icon }
  1094.       TempIcon := TIcon.Create;
  1095.       { Call the custom DRWS routine to get icon for a file }
  1096.       GetIconForFile( Items[ i ] , TempIcon );
  1097.       { Put the icon on the bitmap for the picture via draw }
  1098.       { Note 1 , 1 due to bug in Draw?                      }
  1099.       TempPicture.Bitmap.Canvas.Draw( 1 , 1 , TempIcon );
  1100.       { Create a temporary bitmap }
  1101.       TempBmp := TBitmap.Create;
  1102.       { Set its width to those of the previous object's bitmaps }
  1103.       TempBmp.Width := 16;
  1104.       TempBmp.Height := 15;
  1105.       { Resize the icon's bitmap to the smaller size with stretchdraw }
  1106.       TempBmp.Canvas.StretchDraw( Rect( 1 , 1 , 15 , 14 ) ,
  1107.        TempPicture.Bitmap );
  1108.       { Set the Objects list to the bitmap }
  1109.       Items.Objects[ i ] := TempBmp;
  1110.       { Free the icon each iteration; don't free the TempBmp as list does }
  1111.       TempIcon.Free;
  1112.     end;
  1113.     { Free the TPicture exchange element }
  1114.     TempPicture.Free;
  1115.     {------------------------ end custom code --------------------------------}
  1116.     Change;
  1117.   end;
  1118. end;
  1119.  
  1120. { Use this to respond to dbl-clicking FLB filename }
  1121. procedure TIconFileListBox.TheDblClick(Sender: TObject);
  1122. begin
  1123.   { Call shellexec as a wrapper around ShellExecute API call }
  1124.   { False indicates failure, signal error                    }
  1125.   if not ShellExec( ExpandFileName( Items[ ItemIndex ] ), '' , '', false ,
  1126.    SW_SHOWNORMAL , false ) then MessageDlg('Could not Shell out to ' +
  1127.     Items[ ItemIndex ] , mtError, [mbOK], 0);
  1128. end;
  1129.  
  1130. { Create method for FIP                                }
  1131. constructor TIconFileListBox.Create( AOwner : TComponent );
  1132. begin
  1133.   { call inherited -- VITAL! }
  1134.   inherited Create( AOwner );
  1135.   { set the mouse method }
  1136.   OnDblClick := TheDblClick;
  1137. end;
  1138.  
  1139. { Create method for FIP                                }
  1140. constructor TFileIconPanel.Create( AOwner : TComponent );
  1141. begin
  1142.   { call inherited -- VITAL! }
  1143.   inherited Create( AOwner );
  1144.   { create icon and label components, making self owner/displayer }
  1145.   FTheIcon := TIcon.Create;
  1146.   FTheLabel := TLabel.Create( Self );
  1147.   FThelabel.Parent := Self;
  1148.   { Set own and labels mouse methods to stored methods }
  1149.   OnMouseUp := TheMouseUp;
  1150.   OnMouseDown := TheMouseDown;
  1151.   OnDragOver := TheDragOver;
  1152.   OnDragDrop := TheDragDrop;
  1153.   { Set alignment and autosize properties of the label }
  1154.   FTheLabel.Autosize := false;
  1155.   FTheLabel.Alignment := taCenter;
  1156.   { Set selected to false }
  1157.   Selected := false;
  1158. end;
  1159.  
  1160. procedure TFileIconPanel.WMLButtonDblClk(var Message: TWMLButtonDblClk);
  1161. var CurrentDirectory : String;    { Use to store dirs }
  1162.     TheDrive         : String;    { Get drive letter  }
  1163.     WhichDrive       : Integer;   { Get drive number  }
  1164.     ErrorCheck       : Integer;
  1165.     TheFWB           : TFileWorkBench;
  1166. begin
  1167.   { Create FileWorkBench for later use }
  1168.   TheFWB := TFileWorkBench.Create( Self );
  1169.   { Check for label or FIP sender }
  1170.   if FTheLabel.Caption = '..' then
  1171.   begin { deal with backup request }
  1172.     { Change to new directory }
  1173.     TheFWB.ChangeTheDirectory( '..' );
  1174.     { Call special method due to SendMessage problem! }
  1175.     TFileIconPanelScrollBox( Parent ).Update;
  1176.   end
  1177.   else
  1178.   begin
  1179.     { Check for DRIVE id in name }
  1180.     if Pos( 'DRIVE' , FTheName ) <> 0 then
  1181.     begin { Double Click on a Drive Icon }
  1182.       { Pull out the letter from name }
  1183.       TheDrive := Copy( FtheName , 7 , 1 );
  1184.       { Convert it to a number }
  1185.       WhichDrive := ( Ord( TheDrive[ 1 ] ) - Ord( 'A' )) + 1;
  1186.       TheFWB.ChangeTheDriveAndDirectory( WhichDrive );
  1187.       { Call special method due to SendMessage problem! }
  1188.       TFileIconPanelScrollBox( Parent ).Update;
  1189.     end
  1190.     else
  1191.     begin { Double click on a dir/file icon }
  1192.       if (( FileGetAttr( FTheName ) and faDirectory ) = faDirectory ) then
  1193.       begin { A directory, change to it }
  1194.         { Since full path in name, simply change to it! }
  1195.         TheFWB.ChangeTheDirectory( FTheName );
  1196.         { Call special method due to SendMessage problem! }
  1197.         TFileIconPanelScrollBox( Parent ).Update;
  1198.       end
  1199.       else
  1200.       begin { A file; attempt to shellexecute it }
  1201.         { Call shellexec as a wrapper around ShellExecute API call }
  1202.         { False indicates failure, signal error                    }
  1203.         if not ShellExec( FTheName , '' , '', false , SW_SHOWNORMAL , false )
  1204.          then MessageDlg('Could not Shell out to ' + FTheName , mtError,
  1205.           [mbOK], 0);
  1206.       end;
  1207.     end;
  1208.   end;
  1209.   TheFWB.Free; { This prevents resource leak }
  1210. end;
  1211.  
  1212. { Initialization method for FIP                                         }
  1213. procedure TFileIconPanel.Initialize( PanelX              ,
  1214.                                      PanelY              ,
  1215.                                      PanelWidth          ,
  1216.                                      PanelHeight         ,
  1217.                                      PanelBevelWidth     ,
  1218.                                      LabelFontSize         : Integer;
  1219.                                      PanelColor          ,
  1220.                                      PanelHighlightColor ,
  1221.                                      PanelShadowColor    ,
  1222.                                      LabelTextColor        : TColor;
  1223.                                      TheFilename         ,
  1224.                                      LabelFontName         : String;
  1225.                                      LabelFontStyle        : TFontStyles;
  1226.                                      ExtraData             : Integer );
  1227.  
  1228. var TheLabelHeight ,             { Holder for label pixel height }
  1229.     TheLabelWidth    : Integer;  { Holder for label pixel width  }
  1230.     TheOtherPChar    : PChar;    { Windows ASCIIZ string         }
  1231. begin
  1232.   { Set the basic properties based on imported parameters }
  1233.   Left := PanelX;
  1234.   Top := PanelY;
  1235.   Width := PanelWidth;
  1236.   Height := PanelHeight;
  1237.   Color := PanelColor;
  1238.   BevelWidth := PanelBevelWidth;
  1239.   FHighlightColor := PanelHighlightColor;
  1240.   FShadowColor := PanelShadowColor;
  1241.   FTheName := TheFilename;
  1242.   { If the ExtraData field is non-0 then a drive is being sent in }
  1243.   if ExtraData <> 0 then
  1244.   begin
  1245.     { Use the data field value to determine which icon to get from RES file }
  1246.     case ExtraData of
  1247.       1 : begin
  1248.             GetMem( TheOtherPChar , 255 );
  1249.             StrPCopy( TheOtherPChar , 'FLOPPY35' );
  1250.             FTheIcon.Handle := LoadIcon( hInstance , TheOtherPChar );
  1251.             FreeMem( TheOtherPChar , 255 );
  1252.           end;
  1253.       2 : begin
  1254.             GetMem( TheOtherPChar , 255 );
  1255.             StrPCopy( TheOtherPChar , 'FIXEDHD' );
  1256.             FTheIcon.Handle := LoadIcon( hInstance , TheOtherPChar );
  1257.             FreeMem( TheOtherPChar , 255 );
  1258.           end;
  1259.       3 : begin
  1260.             GetMem( TheOtherPChar , 255 );
  1261.             StrPCopy( TheOtherPChar , 'NETWORKHD' );
  1262.             FTheIcon.Handle := LoadIcon( hInstance , TheOtherPChar );
  1263.             FreeMem( TheOtherPChar , 255 );
  1264.           end;
  1265.       4 : begin
  1266.             GetMem( TheOtherPChar , 255 );
  1267.             StrPCopy( TheOtherPChar , 'CDROM' );
  1268.             FTheIcon.Handle := LoadIcon( hInstance , TheOtherPChar );
  1269.             FreeMem( TheOtherPChar , 255 );
  1270.           end;
  1271.       5 : begin
  1272.             GetMem( TheOtherPChar , 255 );
  1273.             StrPCopy( TheOtherPChar , 'RAM' );
  1274.             FTheIcon.Handle := LoadIcon( hInstance , TheOtherPChar );
  1275.             FreeMem( TheOtherPChar , 255 );
  1276.           end;
  1277.     end;
  1278.     { The FileNme property is already set up for the caption; use directly }
  1279.     FTheLabel.Caption := TheFilename;
  1280.     { Set up the hint for later use (make sure to set ShowHint) }
  1281.     Hint := 'Change to ' + TheFileName;
  1282.     ShowHint := true;
  1283.     { Set up all imported label properties and center it for drawing }
  1284.     with FTheLabel do
  1285.     begin
  1286.       Font.Name := LabelFontName;
  1287.       Font.Size := LabelFontSize;
  1288.       Font.Style := LabelFontStyle;
  1289.       Font.Color := LabelTextColor;
  1290.       Canvas.Brush.Color := PanelColor;
  1291.       Canvas.Font := Font;
  1292.       TheLabelHeight := Canvas.Textheight( Caption ) + 4;
  1293.       TheLabelWidth := Canvas.Textwidth( Caption ) + 4;
  1294.       Left := (( Self.Width - TheLabelWidth ) div 2 ) + 1;
  1295.       Top := ((( Round( Self.Height * 0.25 ) - 6 ) - TheLabelHeight) div 2) + 1;
  1296.       Top := Top + Round( Self.Height * 0.75 );
  1297.       Height := TheLabelHeight;
  1298.       Width := TheLabelWidth;
  1299.     end;
  1300.   end
  1301.   else
  1302.   begin
  1303.     { A file or directory has been sent in; use GetIconForFile to obtain an }
  1304.     { icon either from the file, its owner, or a RES file default.          }
  1305.     GetIconForFile( FTheName , FTheIcon );
  1306.     { Check for the Backup caption and set it specially }
  1307.     if ExtractfileName( FThename ) = '..' then
  1308.     begin
  1309.       FTheLabel.Caption := '..';
  1310.       Hint := 'Up One Level';
  1311.     end
  1312.     else
  1313.     begin
  1314.       { Otherwise just get the filename for the label caption }
  1315.       { And the full path for the hint (used later.)          }
  1316.       FTheLabel.caption := ExtractFileName( UpperCase( FTheName ));
  1317.       Hint := FTheName;
  1318.     end;
  1319.     { Activate showhint so hints are seen }
  1320.     ShowHint := true;
  1321.     { Set label properties with imported values and center for display }
  1322.     with FTheLabel do
  1323.     begin
  1324.       Font.Name := LabelFontName;
  1325.       Font.Size := LabelFontSize;
  1326.       Font.Style := LabelFontStyle;
  1327.       Font.Color := LabelTextColor;
  1328.       Canvas.Brush.Color := PanelColor;
  1329.       Canvas.Font := Font;
  1330.       TheLabelHeight := Canvas.Textheight( Caption ) + 4;
  1331.       TheLabelWidth := Canvas.Textwidth( Caption ) + 4;
  1332.       Left := (( Self.Width - TheLabelWidth ) div 2 ) + 1;
  1333.       Top := ((( Round( Self.Height * 0.25 ) - 6 ) - TheLabelHeight) div 2) + 1;
  1334.       Top := Top + Round( Self.Height * 0.75 );
  1335.       Height := TheLabelHeight;
  1336.       Width := TheLabelWidth;
  1337.     end;
  1338.   end;
  1339. end;
  1340.  
  1341. { Destroy method for FIP }
  1342. destructor TFileIconPanel.Destroy;
  1343. begin
  1344.   { free component resources }
  1345.   FTheIcon.Free;
  1346.   FTheLabel.Free;
  1347.   { call inherited -- VITAL! }
  1348.   inherited Destroy;
  1349. end;
  1350.  
  1351. { Mousedown method for FIP; used to allow dragging }
  1352. procedure TFileIconPanel.TheMouseDown(Sender: TObject;
  1353.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  1354. begin
  1355.   { Begin a conditional drag operation (false allows timer) }
  1356.   TheIOManager.WhichButton := Button;
  1357.   TheIOManager.WhichState := Shift;
  1358.   if Button <> mbRight then BeginDrag( false );
  1359.   { Currently ignore drive clicks }
  1360.   if Pos( 'DRIVE' , FTheName ) > 0 then exit;
  1361.   { Flip status of bevels }
  1362.   if BevelOuter = bvRaised then BevelOuter := bvLowered else
  1363.    BevelOuter := bvRaised;
  1364.   { Flip selected variable }
  1365.   Selected := not Selected;
  1366.   { Set redisplay }
  1367. end;
  1368.  
  1369. { Mouseup Method for FIP; used to allow dragging }
  1370. procedure TFileIconPanel.TheMouseUp(Sender: TObject;
  1371.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  1372. begin
  1373.   { End a drag operation without dropping; if dragged OK }
  1374.   { already handled.                                     }
  1375.   {EndDrag( false );}
  1376.   { If the right button is clicked, perform magic! }
  1377.   if Button = mbRight then
  1378.    TCCFileMgrForm( TFileIconPanelScrollbox( Parent ).
  1379.     TheParentForm ).BitBtn6Click( Self );
  1380.   { Redisplay on general principles }
  1381.   Invalidate;
  1382. end;
  1383.  
  1384. { Use this to generically OK DnD from FIPs }
  1385. procedure TFileIconPanel.TheDragOver(Sender, Source: TObject; X,
  1386.   Y: Integer; State: TDragState; var Accept: Boolean);
  1387. begin
  1388.   { Only accept from FileIconPanel components }
  1389.   if Source is TFileIconPanel then Accept := true else Accept := false;
  1390. end;
  1391.  
  1392. { Use this to accept Drag and Drop from other FIPs }
  1393. procedure TFileIconPanel.TheDragDrop(Sender, Source: TObject; X,
  1394.   Y: Integer);
  1395. var CurrentName ,                 { Holds work name}
  1396.     TheOldString : String;        { Holds Dir      }
  1397.     TargetDir    : String;        { target of op   }
  1398.     TheResult       : Integer;    { Modal res hold }
  1399.     SourceDirectory,
  1400.     TargetDirectory,
  1401.     CurrentDirectory : String;    { Use to store dirs }
  1402.     TheDrive         : String;    { Get drive letter  }
  1403.     WhichDrive       : Integer;   { Get drive number  }
  1404.     ErrorCheck       : Integer;
  1405.     TheFWB           : TFileWorkBench;
  1406.     ThePosition : Integer;
  1407.     Finished : Boolean;
  1408.     TheFIPSB : TFileIconPanelScrollBox;
  1409. begin
  1410.   { If drop target is .. then ignore }
  1411.   if FTheLabel.Caption = '..' then exit;
  1412.   { Likewise ignore Dnd from drive icons }
  1413.   if Pos( 'DRIVE' , TFileIconPanel( Source ).FtheName ) > 0 then exit;
  1414.   { Obtain the parent of the source FIP; may not be self }
  1415.   TheFIPSB := TFileIconPanelScrollBox( TFileIconPanel( Source ).Parent );
  1416.   { Obtain source directory either as Dir or filepath }
  1417.   if (( FileGetAttr( TFileIconPanel( Source ).FTheName )
  1418.    and faDirectory ) = faDirectory ) then
  1419.   begin  { Directory; take whole path }
  1420.     SourceDirectory := TFileIconPanel( Source ).FTheName;
  1421.   end
  1422.   else
  1423.   begin { File; get pathname }
  1424.     SourceDirectory := ExtractFilePath( TFileIconPanel( Source ).FTheName );
  1425.   end;
  1426.   Sourcedirectory := TheFIPSB.TheFWB.ForceTrailingBackSlash( SourceDirectory );
  1427.   if Pos( 'DRIVE' , FTheName ) > 0 then
  1428.   begin { Drop onto a drive icon; perform action to its default dir }
  1429.     { Pull out the letter from name }
  1430.     TheDrive := Copy( FtheName , 7 , 1 );
  1431.     { Convert it to a number }
  1432.     WhichDrive := ( Ord( TheDrive[ 1 ] ) - Ord( 'A' )) + 1;
  1433.     { Determine the target directory and drive }
  1434.     GetDir( WhichDrive , TargetDirectory );
  1435.     TargetDirectory := TheFIPSB.TheFWB.ForceTrailingbackSlash( TargetDirectory );
  1436.     { Check for shift to operate on all selections }
  1437.     if TheIOManager.WasSHIFTPressed then
  1438.     begin { Operate on all selections }
  1439.       { Obtain the parent directory of the FIP dragged over }
  1440.       SourceDirectory := ExtractFilePath( TFileIconPanel( Source ).FTheName );
  1441.       SourceDirectory := TheFIPSB.TheFWB.ForceTrailingBackslash( SourceDirectory );
  1442.       { If SourceDir subset of TargetDir then abort; recursive failure }
  1443.       if Pos( SourceDirectory , TargetDirectory ) > 0 then
  1444.       begin
  1445.         MessageDlg( 'Cannot drag to same directory!',mtError,[mbOK],0 );
  1446.         exit;
  1447.       end;
  1448.       if TargetDirectory[ 1 ] <> SourceDirectory[ 1 ] then
  1449.       begin { Copy to different drives }
  1450.         if TheIOManager.WasALTPressed then
  1451.         begin { ALT overrides and does move }
  1452.           { Set up to get all current selections }
  1453.           ThePosition := 1;
  1454.           finished := false;
  1455.           while not finished do
  1456.           begin
  1457.             CurrentName := TheFIPSB.GetNextSelection( SourceDirectory ,
  1458.                    ThePosition );
  1459.             { If returns blank string then out of selections }
  1460.             if CurrentName = '' then finished := true else
  1461.             begin
  1462.               { If a directory signal error }
  1463.               if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
  1464.               begin
  1465.                 if MessageDlg( 'Move Directory ' + CurrentName + ' to ' +
  1466.                  TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1467.                   TheFIPSB.TheFWB.RecursivelyMoveDirectory( CurrentName ,
  1468.                    TargetDirectory );
  1469.               end
  1470.               else
  1471.               begin
  1472.                 TheFIPSB.TheFWB.MoveTheFile( CurrentName , TargetDirectory );
  1473.               end;
  1474.             end;
  1475.             { Reset to normal cursor }
  1476.             Screen.Cursor := crDefault;
  1477.           end;
  1478.         end
  1479.         else
  1480.         begin { Default is to do copy like file manager }
  1481.           { Set up to get all current selections }
  1482.           ThePosition := 1;
  1483.           finished := false;
  1484.           while not finished do
  1485.           begin
  1486.              CurrentName := TheFIPSB.GetNextSelection( SourceDirectory ,
  1487.                    ThePosition );
  1488.             { If returns blank string then out of selections }
  1489.             if CurrentName = '' then finished := true else
  1490.             begin
  1491.               { If a directory signal error }
  1492.               if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
  1493.               begin
  1494.                 if MessageDlg( 'Copy Directory ' + CurrentName + ' to ' +
  1495.                  TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1496.                   TheFIPSB.TheFWB.RecursivelyCopyDirectory( CurrentName ,
  1497.                    TargetDirectory );
  1498.               end
  1499.               else
  1500.               begin
  1501.                 TheFIPSB.TheFWB.CopyTheFile( CurrentName , TargetDirectory );
  1502.               end;
  1503.             end;
  1504.             { Reset to normal cursor }
  1505.             Screen.Cursor := crDefault;
  1506.           end;
  1507.         end;
  1508.       end
  1509.       else
  1510.       begin { Copy to same drive }
  1511.         if TheIOManager.WasCTRLPressed then
  1512.         begin { CTRL overrides and does copy }
  1513.           { Set up to get all current selections }
  1514.           ThePosition := 1;
  1515.           finished := false;
  1516.           while not finished do
  1517.           begin
  1518.             CurrentName := TheFIPSB.GetNextSelection( SourceDirectory ,
  1519.                    ThePosition );
  1520.             { If returns blank string then out of selections }
  1521.             if CurrentName = '' then finished := true else
  1522.             begin
  1523.               { If a directory signal error }
  1524.               if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
  1525.               begin
  1526.                 if MessageDlg( 'Copy Directory ' + CurrentName + ' to ' +
  1527.                  TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1528.                   TheFIPSB.TheFWB.RecursivelyCopyDirectory( CurrentName ,
  1529.                    TargetDirectory );
  1530.               end
  1531.               else
  1532.               begin
  1533.                 TheFIPSB.TheFWB.CopyTheFile( CurrentName , TargetDirectory );
  1534.               end;
  1535.             end;
  1536.             { Reset to normal cursor }
  1537.             Screen.Cursor := crDefault;
  1538.           end;
  1539.         end
  1540.         else
  1541.         begin { Default is to do move like file manager }
  1542.           { Set up to get all current selections }
  1543.           ThePosition := 1;
  1544.           finished := false;
  1545.           while not finished do
  1546.           begin
  1547.             CurrentName := TheFIPSB.GetNextSelection( SourceDirectory ,
  1548.                    ThePosition );
  1549.             { If returns blank string then out of selections }
  1550.             if CurrentName = '' then finished := true else
  1551.             begin
  1552.               { If a directory signal error }
  1553.               if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
  1554.               begin
  1555.                 if MessageDlg( 'Move Directory ' + CurrentName + ' to ' +
  1556.                  TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1557.                   TheFIPSB.TheFWB.RecursivelyMoveDirectory( CurrentName ,
  1558.                    TargetDirectory );
  1559.               end
  1560.               else
  1561.               begin
  1562.                 TheFIPSB.TheFWB.MoveTheFile( CurrentName , TargetDirectory );
  1563.               end;
  1564.             end;
  1565.             { Reset to normal cursor }
  1566.             Screen.Cursor := crDefault;
  1567.           end;
  1568.         end;
  1569.       end;
  1570.     end
  1571.     else
  1572.     begin { Operate on only source }
  1573.       if TargetDirectory[ 1 ] <> SourceDirectory[ 1 ] then
  1574.       begin { Copy to different drives }
  1575.         if TheIOManager.WasALTPressed then
  1576.         begin { ALT overrides and does move }
  1577.           with Source as TFileIconPanel do
  1578.           begin
  1579.             if MessageDlg( 'Move ' + FTheName + ' to ' +
  1580.              TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1581.               TheFIPSB.TheFWB.MoveTheFile( FTheName , TargetDirectory );
  1582.           end;
  1583.         end
  1584.         else
  1585.         begin { Default is to do copy like file manager }
  1586.           with Source as TFileIconPanel do
  1587.           begin
  1588.             if MessageDlg( 'Copy ' + FTheName + ' to ' +
  1589.              TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1590.               TheFIPSB.TheFWB.CopyTheFile( FtheName , TargetDirectory );
  1591.           end;
  1592.         end;
  1593.       end
  1594.       else
  1595.       begin { Copy to same drive }
  1596.         if TheIOManager.WasCTRLPressed then
  1597.         begin { CTRL overrides and does copy }
  1598.           with Source as TFileIconPanel do
  1599.           begin
  1600.             if MessageDlg( 'Copy ' + FTheName + ' to ' +
  1601.              TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1602.               TheFIPSB.TheFWB.CopyTheFile( FTheName , TargetDirectory );
  1603.           end;
  1604.         end
  1605.         else
  1606.         begin { Default is to do move like file manager }
  1607.           with Source as TFileIconPanel do
  1608.           begin
  1609.             if MessageDlg( 'Move ' + FTheName + ' to ' +
  1610.              TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1611.              TheFIPSB.TheFWB.MoveTheFile( FtheName , TargetDirectory );
  1612.           end;
  1613.         end;
  1614.       end;
  1615.     end;
  1616.   end
  1617.   else
  1618.   begin { Drop onto dir or file icon }
  1619.     if (( FileGetAttr( FTheName ) and faDirectory ) = faDirectory ) then
  1620.     begin { Drop onto a directory; use its path as target }
  1621.       TargetDirectory := FTheName;
  1622.     end
  1623.     else
  1624.     begin { Drop onto a file; use its parent as target }
  1625.       TargetDirectory := ExtractFilePath( FTheName );
  1626.     end;
  1627.     Targetdirectory := TheFIPSB.TheFWB.ForceTrailingbackslash( TargetDirectory );
  1628.     { Check for shift to operate on all selections }
  1629.     if TheIOManager.WasSHIFTPressed then
  1630.     begin { Operate on all selections }
  1631.       { Obtain the parent directory of the FIP dragged over }
  1632.       SourceDirectory := ExtractFilePath( TFileIconPanel( Source ).FTheName );
  1633.       SourceDirectory := TheFIPSB.TheFWB.ForceTrailingBackslash( SourceDirectory );
  1634.       { If SourceDir subset of TargetDir then abort; recursive failure }
  1635.       if Pos( SourceDirectory , TargetDirectory ) > 0 then
  1636.       begin
  1637.         MessageDlg( 'Cannot drag to same directory!',mtError,[mbOK],0 );
  1638.         exit;
  1639.       end;
  1640.       if TargetDirectory[ 1 ] <> SourceDirectory[ 1 ] then
  1641.       begin { Copy to different drives }
  1642.         if TheIOManager.WasALTPressed then
  1643.         begin { ALT overrides and does move }
  1644.           { Set up to get all current selections }
  1645.           ThePosition := 1;
  1646.           finished := false;
  1647.           while not finished do
  1648.           begin
  1649.              CurrentName := TheFIPSB.GetNextSelection( SourceDirectory ,
  1650.                    ThePosition );
  1651.             { If returns blank string then out of selections }
  1652.             if CurrentName = '' then finished := true else
  1653.             begin
  1654.               { If a directory signal error }
  1655.               if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
  1656.               begin
  1657.                 if MessageDlg( 'Move Directory ' + CurrentName + ' to ' +
  1658.                  TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1659.                   TheFIPSB.TheFWB.RecursivelyMoveDirectory( CurrentName ,
  1660.                    TargetDirectory );
  1661.               end
  1662.               else
  1663.               begin
  1664.                 TheFIPSB.TheFWB.MoveTheFile( CurrentName , TargetDirectory );
  1665.               end;
  1666.             end;
  1667.             { Reset to normal cursor }
  1668.             Screen.Cursor := crDefault;
  1669.           end;
  1670.         end
  1671.         else
  1672.         begin { Default is to do copy like file manager }
  1673.           { Set up to get all current selections }
  1674.           ThePosition := 1;
  1675.           finished := false;
  1676.           while not finished do
  1677.           begin
  1678.             CurrentName := TheFIPSB.GetNextSelection( SourceDirectory ,
  1679.                    ThePosition );
  1680.             { If returns blank string then out of selections }
  1681.             if CurrentName = '' then finished := true else
  1682.             begin
  1683.               { If a directory signal error }
  1684.               if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
  1685.               begin
  1686.                 if MessageDlg( 'Copy Directory ' + CurrentName + ' to ' +
  1687.                  TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1688.                   TheFIPSB.TheFWB.RecursivelyCopyDirectory( CurrentName ,
  1689.                    TargetDirectory );
  1690.               end
  1691.               else
  1692.               begin
  1693.                 TheFIPSB.TheFWB.CopyTheFile( CurrentName , TargetDirectory );
  1694.               end;
  1695.             end;
  1696.             { Reset to normal cursor }
  1697.             Screen.Cursor := crDefault;
  1698.           end;
  1699.         end;
  1700.       end
  1701.       else
  1702.       begin { Copy to same drive }
  1703.         if TheIOManager.WasCTRLPressed then
  1704.         begin { CTRL overrides and does copy }
  1705.           { Set up to get all current selections }
  1706.           ThePosition := 1;
  1707.           finished := false;
  1708.           while not finished do
  1709.           begin
  1710.             { Call generic file getting routine based on current view}
  1711.              CurrentName := TheFIPSB.GetNextSelection( SourceDirectory ,
  1712.                    ThePosition );
  1713.             { If returns blank string then out of selections }
  1714.             if CurrentName = '' then finished := true else
  1715.             begin
  1716.               { If a directory signal error }
  1717.               if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
  1718.               begin
  1719.                 if MessageDlg( 'Copy Directory ' + CurrentName + ' to ' +
  1720.                  TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1721.                   TheFIPSB.TheFWB.RecursivelyCopyDirectory( CurrentName ,
  1722.                    TargetDirectory );
  1723.               end
  1724.               else
  1725.               begin
  1726.                 TheFIPSB.TheFWB.CopyTheFile( CurrentName , TargetDirectory );
  1727.               end;
  1728.             end;
  1729.             { Reset to normal cursor }
  1730.             Screen.Cursor := crDefault;
  1731.           end;
  1732.         end
  1733.         else
  1734.         begin { Default is to do move like file manager }
  1735.           { Set up to get all current selections }
  1736.           ThePosition := 1;
  1737.           finished := false;
  1738.           while not finished do
  1739.           begin
  1740.             { Call generic file getting routine based on current view}
  1741.               CurrentName := TheFIPSB.GetNextSelection( SourceDirectory ,
  1742.                    ThePosition );
  1743.             { If returns blank string then out of selections }
  1744.             if CurrentName = '' then finished := true else
  1745.             begin
  1746.               { If a directory signal error }
  1747.               if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
  1748.               begin
  1749.                 if MessageDlg( 'Move Directory ' + CurrentName + ' to ' +
  1750.                  TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1751.                   TheFIPSB.TheFWB.RecursivelyMoveDirectory( CurrentName ,
  1752.                    TargetDirectory );
  1753.               end
  1754.               else
  1755.               begin
  1756.                 TheFIPSB.TheFWB.MoveTheFile( CurrentName , TargetDirectory );
  1757.               end;
  1758.             end;
  1759.             { Reset to normal cursor }
  1760.             Screen.Cursor := crDefault;
  1761.           end;
  1762.         end;
  1763.       end;
  1764.     end
  1765.     else
  1766.     begin { Operate on only source }
  1767.       if TargetDirectory[ 1 ] <> SourceDirectory[ 1 ] then
  1768.       begin { Copy to different drives }
  1769.         if TheIOManager.WasALTPressed then
  1770.         begin { ALT overrides and does move }
  1771.           with Source as TFileIconPanel do
  1772.           begin
  1773.             if (( FileGetAttr( FTheName ) and faDirectory ) = faDirectory ) then
  1774.             begin
  1775.               if MessageDlg( 'Move Directory ' + FTheName + ' to ' +
  1776.                TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1777.                 TheFIPSB.TheFWB.RecursivelyMoveDirectory( FtheName ,
  1778.                  TargetDirectory );
  1779.             end
  1780.             else
  1781.             begin
  1782.               if MessageDlg( 'Move ' + FTheName + ' to ' +
  1783.                TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1784.                 TheFIPSB.TheFWB.MoveTheFile( FTheName , TargetDirectory );
  1785.             end;
  1786.           end;
  1787.         end
  1788.         else
  1789.         begin { Default is to do copy like file manager }
  1790.           with Source as TFileIconPanel do
  1791.           begin
  1792.             if (( FileGetAttr( FTheName ) and faDirectory ) = faDirectory ) then
  1793.             begin
  1794.               if MessageDlg( 'Copy Directory ' + FtheName + ' to ' +
  1795.                TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1796.                 TheFIPSB.TheFWB.RecursivelyCopyDirectory( FtheName ,
  1797.                  TargetDirectory );
  1798.             end
  1799.             else
  1800.             begin
  1801.               if MessageDlg( 'Copy ' + FTheName + ' to ' +
  1802.                TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1803.                 TheFIPSB.TheFWB.CopyTheFile( FTheName , TargetDirectory );
  1804.             end;
  1805.           end;
  1806.         end;
  1807.       end
  1808.       else
  1809.       begin { Copy to same drive }
  1810.         if TheIOManager.WasCTRLPressed then
  1811.         begin { CTRL overrides and does copy }
  1812.           with Source as TFileIconPanel do
  1813.           begin
  1814.             if (( FileGetAttr( FTheName ) and faDirectory ) = faDirectory ) then
  1815.             begin
  1816.               if MessageDlg( 'Copy Directory ' + FtheName + ' to ' +
  1817.                TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1818.                 TheFIPSB.TheFWB.RecursivelyCopyDirectory( FtheName ,
  1819.                  TargetDirectory );
  1820.             end
  1821.             else
  1822.             begin
  1823.               if MessageDlg( 'Copy ' + FTheName + ' to ' +
  1824.                TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1825.                 TheFIPSB.TheFWB.CopyTheFile( FTheName , TargetDirectory );
  1826.             end;
  1827.           end;
  1828.         end
  1829.         else
  1830.         begin { Default is to do move like file manager }
  1831.           with Source as TFileIconPanel do
  1832.           begin
  1833.             if (( FileGetAttr( FTheName ) and faDirectory ) = faDirectory ) then
  1834.             begin
  1835.               if MessageDlg( 'Move Directory ' + FtheName + ' to ' +
  1836.                TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1837.                 TheFIPSB.TheFWB.RecursivelyMoveDirectory( FtheName ,
  1838.                  TargetDirectory );
  1839.             end
  1840.             else
  1841.             begin
  1842.               if MessageDlg( 'Move ' + FTheName + ' to ' +
  1843.                TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1844.                 TheFIPSB.TheFWB.MoveTheFile( FTheName , TargetDirectory );
  1845.             end;
  1846.           end;
  1847.         end;
  1848.       end;
  1849.     end;
  1850.   end;
  1851.   { Call special method due to SendMessage problem! }
  1852.   TFileIconPanelScrollBox( TFileIconPanel( Source ).Parent ).Update;
  1853.   TFileIconPanelScrollBox( Parent ).Update;
  1854. end;
  1855.  
  1856. { Paint method for FIP; overrides normal paint }
  1857. procedure TFileIconPanel.Paint;
  1858. var
  1859.   TheOtherRect   : TRect;   { Holds clientrect   }
  1860.   TopColor     ,            { Holds bright color }
  1861.   BottomColor    : TColor;  { Holds dark color   }
  1862.  
  1863. { These methods are from Borland Intl., copyright 1995 }
  1864. procedure Frame3D(    Canvas       : TCanvas;
  1865.                   var TheRect      : TRect;
  1866.                       TopColor   ,
  1867.                       BottomColor  : TColor;
  1868.                       Width        : Integer );
  1869.  
  1870. procedure DoRect;
  1871. var
  1872.   TopRight, BottomLeft: TPoint;
  1873. begin
  1874.   with Canvas, TheRect do
  1875.   begin
  1876.     TopRight.X := Right;
  1877.     TopRight.Y := Top;
  1878.     BottomLeft.X := Left;
  1879.     BottomLeft.Y := Bottom;
  1880.     Pen.Color := TopColor;
  1881.     PolyLine([BottomLeft, TopLeft, TopRight]);
  1882.     Pen.Color := BottomColor;
  1883.     Dec(BottomLeft.X);
  1884.     PolyLine([TopRight, BottomRight, BottomLeft]);
  1885.   end;
  1886. end;
  1887.  
  1888. begin
  1889.   Canvas.Pen.Width := 1;
  1890.   Dec(TheRect.Bottom); Dec(TheRect.Right);
  1891.   while Width > 0 do
  1892.   begin
  1893.     Dec(Width);
  1894.     DoRect;
  1895.     InflateRect(TheRect, -1, -1);
  1896.   end;
  1897.   Inc(TheRect.Bottom); Inc(TheRect.Right);
  1898. end;
  1899.  
  1900. procedure AdjustColors(Bevel: TPanelBevel);
  1901. begin
  1902.   TopColor := FHighlightColor;
  1903.   if Bevel = bvLowered then TopColor := FShadowColor;
  1904.   BottomColor := FShadowColor;
  1905.   if Bevel = bvLowered then BottomColor := FHighlightColor;
  1906. end;
  1907.  
  1908. { Custom code begins here }
  1909. begin
  1910.   { Get the rectangle of the control with API/method call }
  1911.   TheOtherRect := GetClientRect;
  1912.   { draw basic rectangle with basic color }
  1913.   with Canvas do
  1914.   begin
  1915.     Brush.Color := Color;
  1916.     FillRect(TheOtherRect);
  1917.   end;
  1918.   { Set up for top "icon" frame  and draw it with frame3d }
  1919.   TheOtherRect.Right := Width;
  1920.   TheOtherRect.Bottom := Round( Height * 0.75 ) - 6 ;
  1921.   if BevelOuter <> bvNone then
  1922.   begin
  1923.     AdjustColors(BevelOuter);
  1924.     Frame3D(Canvas, TheOtherRect, TopColor, BottomColor, BevelWidth);
  1925.   end;
  1926.   Frame3D(Canvas, TheOtherRect, Color, Color, BorderWidth);
  1927.   if BevelInner <> bvNone then
  1928.   begin
  1929.     AdjustColors(BevelInner);
  1930.     Frame3D(Canvas, TheOtherRect, TopColor, BottomColor, BevelWidth);
  1931.   end;
  1932.   { Do the same for the lower "label" frame }
  1933.   TheOtherRect.Top := Round( Height * 0.75 ) - 5;
  1934.   TheOtherRect.Left := 0;
  1935.   TheOtherRect.Bottom := Height;
  1936.   TheOtherRect.Right := Width;
  1937.   if BevelOuter <> bvNone then
  1938.   begin
  1939.     AdjustColors(BevelOuter);
  1940.     Frame3D(Canvas, TheOtherRect, TopColor, BottomColor, BevelWidth);
  1941.   end;
  1942.   Frame3D(Canvas, TheOtherRect, Color, Color, BorderWidth);
  1943.   if BevelInner <> bvNone then
  1944.   begin
  1945.     AdjustColors(BevelInner);
  1946.     Frame3D(Canvas, TheOtherRect, TopColor, BottomColor, BevelWidth);
  1947.   end;
  1948.   { Then draw the icon using canvas draw method }
  1949.   Canvas.Draw( (( Width - 32 ) div 2 ) + 1 ,
  1950.   ((( Round( Height * 0.75 ) - 6 ) - 32 ) div 2 ) + 1 , FTheIcon );
  1951. end;
  1952.  
  1953. { This procedure clears a scrollbox of all FileIconPanels }
  1954. procedure TFileIconPanelScrollbox.ClearTheFIPs;
  1955. var Counter_1 : Integer;
  1956.     TheComponent : TComponent;
  1957. begin
  1958.   { Note that must use while loop since component count continually }
  1959.   { decreases as removes are made!                                  }
  1960.   while ComponentCount > 0 do
  1961.   begin
  1962.     { Save the component as a generic TComponent }
  1963.     TheComponent := Components[ 0 ];
  1964.     { Call removecomponent to pull it out of the owner list for sb }
  1965.     { This avoids GPF when freeing the sb.                         }
  1966.     RemoveComponent( Components[ 0 ]);
  1967.     if ControlCount > 0 then
  1968.      RemoveControl( Controls[ 0 ] );
  1969.     { Typecast the pointer and free it to release memory and res. }
  1970.     TheParentForm.InsertComponent( TheComponent );
  1971.   end;
  1972. end;
  1973.  
  1974. { This procedure scans for drives and obtains their type and creates file }
  1975. { icon panels to represent them.                                          }
  1976. procedure TFileIconPanelScrollBox.AddDriveIcons( var XCounter ,
  1977.            YCounter : Integer );
  1978. type
  1979.   { This if from filectrl unit; reproduce here for completeness }
  1980.   TDriveType = (dtUnknown, dtNoDrive, dtFloppy, dtFixed, dtNetwork, dtCDROM,
  1981.                 dtRAM);
  1982. var
  1983.   DrivePC         : array[0..256] of char;
  1984.   DriveNum        : Integer;         { Used to get next drive via DOS fn   }
  1985.   IconType        : Integer;         { Used to hold icon type (defacto dt) }
  1986.   DriveChar       : Char;            { Used to hold drive letter           }
  1987.   DriveType       : TDriveType;      { Used for set-valued drive type      }
  1988.   Finished        : Boolean;         { Loop flag                           }
  1989.   TheFIP          : TFileIconPanel;  { Generic FileIconPanel variable      }
  1990.   ButtonColor   ,                    { Main panel color                    }
  1991.   ButtonHLColor ,                    { Bright panel color                  }
  1992.   ButtonSColor  ,                    { Dark panel color                    }
  1993.   Textcolor       : TColor;          { Label text color                    }
  1994.  
  1995. (*{ This code is from the FileCtrl Unit; copyright Borland Intl 1995      }
  1996. { Check whether drive is a CD-ROM.  Returns True if MSCDEX is installed }
  1997. {  and the drive is using a CD driver                                   }
  1998.  
  1999. function IsCDROM(DriveNum: Integer): Boolean; assembler;
  2000. asm
  2001.   MOV   AX,1500h { look for MSCDEX }
  2002.   XOR   BX,BX
  2003.   INT   2fh
  2004.   OR    BX,BX
  2005.   JZ    @Finish
  2006.   MOV   AX,150Bh { check for using CD driver }
  2007.   MOV   CX,DriveNum
  2008.   INT   2fh
  2009.   OR    AX,AX
  2010.   @Finish:
  2011. end;
  2012.  
  2013. { This code is from the FileCtrl Unit; copyright Borland Intl 1995      }
  2014. { Check whether drive is a RAM drive.                                   }
  2015. function IsRAMDrive(DriveNum: Integer): Boolean; assembler;
  2016. var
  2017.   TempResult: Boolean;
  2018. asm
  2019.   MOV   TempResult,False
  2020.   PUSH  DS
  2021.   MOV   BX,SS
  2022.   MOV   DS,BX
  2023.   SUB   SP,0200h
  2024.   MOV   BX,SP
  2025.   MOV   AX,DriveNum
  2026.   MOV   CX,1
  2027.   XOR   DX,DX
  2028.   INT   25h  { read boot sector }
  2029.   ADD   SP,2
  2030.   JC    @ItsNot
  2031.   MOV   BX,SP
  2032.   CMP   BYTE PTR SS:[BX+15h],0F8h  { reverify fixed disk }
  2033.   JNE   @ItsNot
  2034.   CMP   BYTE PTR SS:[BX+10h],1  { check for single FAT }
  2035.   JNE   @ItsNot
  2036.   MOV   TempResult,True
  2037.   @ItsNot:
  2038.   ADD   SP,0200h
  2039.   POP   DS
  2040.   MOV   AL, TempResult
  2041. end;
  2042.  
  2043. { This code is from the FileCtrl Unit; copyright Borland Intl 1995      }
  2044. { Finds the type of a drive letter.                                     }
  2045. function FindDriveType(DriveNum: Integer): TDriveType;
  2046. begin
  2047.   Result := TDriveType(GetDriveType(DriveNum));
  2048.   if (Result = dtFixed) or (Result = dtNetwork) then
  2049.   begin
  2050.     if IsCDROM(DriveNum) then Result := dtCDROM
  2051.     else if (Result = dtFixed) then
  2052.     begin
  2053.         { do not check for RAMDrive under Windows NT }
  2054.       if ((GetWinFlags and $4000) = 0) and IsRAMDrive(DriveNum) then
  2055.         Result := dtRAM;
  2056.     end;
  2057.   end;
  2058. end;*)
  2059.  
  2060. begin
  2061.   { Set the button colors to an aquamarine color scheme for drives }
  2062.   ButtonColor := clTeal;
  2063.   ButtonHLColor := clAqua;
  2064.   ButtonSColor := clNavy;
  2065.   TextColor := clblack;
  2066.   { Set initial variables before looping for all drives }
  2067.   finished := false;
  2068.   DriveNum := 0;
  2069.   while not finished do
  2070.   begin
  2071.     { Start with no drive found }
  2072.     IconType := 0;
  2073.     (*=============REMOVED DUE TO WINDOWS 95=========
  2074.     { Call the Borland method to get the drive info }
  2075.     DriveType := FindDriveType(DriveNum);
  2076.     ===============END WINDOWS 95 REMOVAL==========*)
  2077.     { Set its letter and make it uppercase }
  2078.     DriveChar := Chr(DriveNum + ord('a'));
  2079.     DriveChar := Upcase(DriveChar);
  2080.     StrPCopy( DrivePC , DriveChar + ':\' );
  2081.     {*&&&&&&&&&&&&&&&  WIN 95 CALL  &&&&&&&&&&&&&&&&&&&*}
  2082.     DriveType := TDriveType(GetDriveType( DrivePC ));
  2083.     { Assign an icon based on the drive type; if no drive exists type is nil }
  2084.     case DriveType of
  2085.       dtFloppy  : IconType := 1;
  2086.       dtFixed   : IconType := 2;
  2087.       dtNetwork : IconType := 3;
  2088.       dtCDROM   : IconType := 4;
  2089.       dtRAM     : IconType := 5;
  2090.     end;
  2091.     { Set to check next drive letter }
  2092.     DriveNum := DriveNum + 1;
  2093.     { But if no match then out of drives so set exit flag }
  2094.     if IconType = 0 then finished := true;
  2095.     { If drive was valid then set up the new FileIconPanel on the imported }
  2096.     { Scrollbox                                                            }
  2097.     if not finished then
  2098.     begin
  2099.       { Create the FileIconPanel and set its parent for memory mgmt and display}
  2100.       TheFIP := TFileIconPanel.Create( Self );
  2101.       TheFIP.Parent := Self;
  2102.       { Call its initialize method with imported position values and the   }
  2103.       { preset color scheme, a drive caption, and a minimum font. Note the }
  2104.       { setting of the ExtraData field to non-zero; this signals a drive   }
  2105.       { rather than a file being sent in.                                  }
  2106.       TheFIP.Initialize((( XCounter - 1 ) * TheIconSpacing ),
  2107.        (( YCounter - 1  ) * TheIconSpacing ) , TheIconSize , TheIconSize , 3 ,
  2108.         7 , ButtonColor, ButtonHLColor,
  2109.        ButtonSColor , TextColor , 'DRIVE ' + DriveChar + ':' , 'MS Serif' , [] ,
  2110.        IconType );
  2111.       { Increment the column counter; if it exceeds max move to new row      }
  2112.       { Note that these are 'var' parameters and will export final position. }
  2113.       XCounter := XCounter + 1;
  2114.       if XCounter > MaxIconsInARow then
  2115.       begin
  2116.         XCounter := 1;
  2117.         YCounter := YCounter + 1;
  2118.       end;
  2119.     end;
  2120.   end;
  2121. end;
  2122.  
  2123. { This procedure assigns colors to FIP's based on file attributes }
  2124. procedure TFileIconPanelScrollBox.GetColorsForFileIcon( TheFile : String;
  2125.            var BC , HC , SC , TC : TColor );
  2126. var AmADir      ,             { Booleans hold file attribs }
  2127.     AmAnArchive ,
  2128.     AmAVolumeId ,
  2129.     AmHidden    ,
  2130.     AmReadOnly  ,
  2131.     AmSystem      : Boolean;
  2132. begin
  2133.   { Make the call to internal fileworkbench to set attributes }
  2134.   TheFWB.GetFileAttributes( TheFile , AmADir , AmAnArchive , AmAVolumeId ,
  2135.    AmHidden , AmReadOnly , AmSystem );
  2136.   { Volume ID has no subtypes }
  2137.   if AmAVolumeID then
  2138.   begin
  2139.     BC := clOlive;
  2140.     HC := clYellow;
  2141.     SC := clBlack;
  2142.     TC := clWhite;
  2143.     exit;
  2144.   end;
  2145.   { Check all directory combinations }
  2146.   if AmADir then
  2147.   begin
  2148.     BC := clNavy;
  2149.     HC := clBlue;
  2150.     SC := clBlack;
  2151.     TC := clWhite;
  2152.     if AmHidden then
  2153.     begin
  2154.       if AmReadOnly then
  2155.       begin
  2156.         if AmSystem then
  2157.         begin { One HECK of a file! }
  2158.           BC := clBlack;
  2159.           HC := clSilver;
  2160.           SC := clGray;
  2161.           TC := clWhite;
  2162.         end
  2163.         else
  2164.         begin { Dir,RO,Hid }
  2165.           BC := clMaroon;
  2166.           HC := clFuchsia;
  2167.           SC := clGreen;
  2168.           TC := clWhite;
  2169.         end;
  2170.       end
  2171.       else
  2172.       begin { Dir,Hid }
  2173.         BC := clPurple;
  2174.         HC := clFuchsia;
  2175.         SC := clBlack;
  2176.         TC := clWhite;
  2177.       end;
  2178.     end
  2179.     else
  2180.     begin
  2181.       if AmReadOnly then
  2182.       begin
  2183.         if AmSystem then
  2184.         begin { Dir,RO,Sys }
  2185.           BC := clMaroon;
  2186.           HC := clLime;
  2187.           SC := clGreen;
  2188.           TC := clWhite;
  2189.         end
  2190.         else
  2191.         begin { Dir,RO }
  2192.           BC := clGreen;
  2193.           HC := clLime;
  2194.           SC := clBlack;
  2195.           TC := clWhite;
  2196.         end;
  2197.       end
  2198.       else
  2199.       begin
  2200.         if AmSystem then
  2201.         begin { Dir,Sys }
  2202.           BC := clMaroon;
  2203.           HC := clRed;
  2204.           SC := clBlack;
  2205.           TC := clWhite;
  2206.         end;
  2207.       end;
  2208.     end;
  2209.   end
  2210.   else { Archive Only; check all combinations }
  2211.   begin
  2212.     BC := clSilver;
  2213.     HC := clWhite;
  2214.     SC := clGray;
  2215.     TC := clBlack;
  2216.     if AmHidden then
  2217.     begin
  2218.       if AmReadOnly then
  2219.       begin
  2220.         if AmSystem then
  2221.         begin { Hid,RO,Sys }
  2222.           BC := clRed;
  2223.           HC := clLime;
  2224.           SC := clPurple;
  2225.           TC := clBlack;
  2226.         end
  2227.         else
  2228.         begin { RO,Hid }
  2229.           BC := clLime;
  2230.           HC := clFuchsia;
  2231.           SC := clMaroon;
  2232.           TC := clBlack;
  2233.         end;
  2234.       end
  2235.       else
  2236.       begin { Hid }
  2237.         BC := clFuchsia;
  2238.         HC := clWhite;
  2239.         SC := clPurple;
  2240.         TC := clBlack;
  2241.       end;
  2242.     end
  2243.     else
  2244.     begin
  2245.       if AmReadOnly then
  2246.       begin
  2247.         if AmSystem then
  2248.         begin { RO,Sys }
  2249.           BC := clRed;
  2250.           HC := clLime;
  2251.           SC := clMaroon;
  2252.           TC := clBlack;
  2253.         end
  2254.         else
  2255.         begin { RO }
  2256.           BC := clLime;
  2257.           HC := clWhite;
  2258.           SC := clGreen;
  2259.           TC := clBlack;
  2260.         end;
  2261.       end
  2262.       else
  2263.       begin
  2264.         if AmSystem then
  2265.         begin { System }
  2266.           BC := clRed;
  2267.           HC := clWhite;
  2268.           SC := clMaroon;
  2269.           TC := clBlack;
  2270.         end;
  2271.       end;
  2272.     end;
  2273.   end;
  2274. end;
  2275.  
  2276. { This procedure gets all icons for an given directory, including drives and }
  2277. { standard subdirectories. It does not get special combinations or h/ro/sys  }
  2278. procedure TFileIconPanelScrollbox.GetIconsForEntireDirectory(
  2279.             TargetPath  : String );
  2280. var Finished        : Boolean;         { Loop flag              }
  2281.     TheSR           : TSearchRec;      { Searchrecord for FF/FN }
  2282.     TheResult       : Integer;         { return variable        }
  2283.     TempPath        : String;          { path for FF/FN         }
  2284.     TheFIP          : TFileIconPanel;  { generic FIP holder     }
  2285.     RowCounter    ,                    { position in row of FIP }
  2286.     ColumnCounter   : Integer;         { position in col of FIP }
  2287.     ButtonColor   ,                    { main panel color       }
  2288.     ButtonHLColor ,                    { bright panel color     }
  2289.     ButtonSColor  ,                    { dark panel color       }
  2290.     Textcolor       : TColor;          { label text color       }
  2291.     IsADir ,                           { Variable for file attr }
  2292.     IsAnArchive ,
  2293.     IsAVolumeID,
  2294.     IsAReadOnlyFile,
  2295.     IsAHiddenFile ,
  2296.     IsASystemFile     : Boolean;
  2297.     MaxTextLength     : Integer;       { Used to safely set size}
  2298. begin
  2299.   { hide during refresh }
  2300.   Visible := false;
  2301.   { Get the icon sizes }
  2302.   TheFIP := TFileIconPanel.Create( Self );
  2303.   TheFIP.Parent := Self;
  2304.   TheFIP.FTheLabel.Canvas.Font.Name := 'MS Serif';
  2305.   TheFIP.FTheLabel.Canvas.Font.Size := 7;
  2306.   MaxTextLength := TheFIP.FTheLabel.Canvas.TextWidth( 'COMMAND.COM' );
  2307.   TheFIP.Free;
  2308.   TheIconSize := MaxTextLength + 13;
  2309.   TheIconSpacing := TheIconSize + 5;
  2310.   { Set up maximum icons per row based on screen size }
  2311.   MaxIconsInARow := ( Screen.Width div TheIconSpacing );
  2312.   { Set up the position counters }
  2313.   RowCounter := 1;
  2314.   ColumnCounter := 1;
  2315.   { Get the drives for the current machine }
  2316.   AddDriveIcons( ColumnCounter , RowCounter  );
  2317.   { Set up the initial variables }
  2318.   Finished := false;
  2319.   TempPath := TargetPath + '*.*';
  2320.   { Make the call to FindFirst set to get any file; will return '.' }
  2321.   { so discard it.                                                  }
  2322.   TheResult := FindFirst( TempPath , faAnyFile , TheSR );
  2323.   { loop through all files in the directory and look for directories }
  2324.   while not Finished do
  2325.   begin
  2326.     { Make call to FindNext, using only SearchRecord from FindFirst }
  2327.     TheResult := FindNext( TheSR );
  2328.     { A -1 result means no more files so exit }
  2329.     if TheResult <> 0 then finished := true else
  2330.     begin
  2331.       { Otherwise check for a directory attribute }
  2332.       if (( FileGetAttr( TargetPath + TheSR.Name ) and faDirectory ) =
  2333.        faDirectory ) then
  2334.       begin
  2335.         GetColorsForFileIcon( TargetPath + TheSR.Name , ButtonColor ,
  2336.          ButtonHLColor , ButtonSColor , TextColor );
  2337.         { If found create a new FileIconPanel on the imported scrollbox }
  2338.         { Note sending 0 ExtraData parameter to indicate file not drive }
  2339.         TheFIP := TFileIconPanel.Create( Self );
  2340.         TheFIP.Parent := Self;
  2341.         TheFIP.Initialize((( ColumnCounter - 1 ) * TheIconSpacing ),
  2342.          (( RowCounter - 1  ) * TheIconSpacing ) , TheIconSize, TheIconSize ,
  2343.           3 , 7 , ButtonColor, ButtonHLColor , ButtonSColor , TextColor ,
  2344.            TargetPath + TheSr.Name , 'MS Serif' , [] , 0 );
  2345.         { Increment column counter and move to new row if past limit }
  2346.         ColumnCounter := ColumnCounter + 1;
  2347.         if ColumnCounter > MaxIconsInARow then
  2348.         begin
  2349.           ColumnCounter := 1;
  2350.           RowCounter := RowCounter + 1;
  2351.         end;
  2352.       end;
  2353.     end;
  2354.   end;
  2355.   { Set up new initialization variables }
  2356.   Finished := false;
  2357.   TempPath := TargetPath + '*.*';
  2358.   { Make needed call to FindFirst and discard '.' }
  2359.   TheResult := FindFirst( TempPath , faAnyFile , TheSR );
  2360.   while not Finished do
  2361.   begin
  2362.     { Loop through file again, this time getting only archive files }
  2363.     TheResult := FindNext( TheSR );
  2364.     { Result of -1 indicates no more files }
  2365.     if TheResult <> 0 then Finished := true else
  2366.     begin
  2367.       { If faArchive file then add new FileIconPanel }
  2368.       TheFWB.GetFileAttributes(( Targetpath + TheSR.Name ) , IsADir ,
  2369.        IsAnArchive , IsAVolumeId , IsAHiddenFile , IsAReadOnlyFile ,
  2370.         IsASystemFile );
  2371.       if (( IsAnArchive ) and ( not IsADir )) then
  2372.       begin
  2373.         GetColorsForFileIcon( TargetPath + TheSR.Name , ButtonColor ,
  2374.          ButtonHLColor , ButtonSColor , TextColor );
  2375.         { Initialize new FileIconPanel and call initialize, sending 0 ED }
  2376.         TheFIP := TFileIconPanel.Create( Self );
  2377.         TheFIP.Parent := Self;
  2378.         TheFIP.Initialize((( ColumnCounter - 1 ) * TheIconSpacing ),
  2379.          (( RowCounter - 1  ) * TheIconSpacing ) , TheIconSize , TheIconSize ,
  2380.           3 , 7 , ButtonColor, ButtonHLColor , ButtonSColor , TextColor ,
  2381.            TargetPath + TheSr.Name , 'MS Serif' , [] , 0 );
  2382.         { Increment column counter and if needed row counter }
  2383.         ColumnCounter := ColumnCounter + 1;
  2384.         if ColumnCounter > MaxIconsInARow then
  2385.         begin
  2386.           ColumnCounter := 1;
  2387.           RowCounter := RowCounter + 1;
  2388.         end;
  2389.       end;
  2390.     end;
  2391.   end;
  2392.   { Reset to visible }
  2393.   Visible := true;
  2394. end;
  2395.  
  2396. { Update method for FIPscrollbox }
  2397. procedure TFileIconPanelScrollBox.Update;
  2398. begin
  2399.   IconsNeedRefreshing := true;
  2400.   { Force a repaint }
  2401.   InvalidateRect( TheStoredHandle , nil , true );
  2402. end;
  2403.  
  2404. { Create method for FIPScrollbox }
  2405. constructor TFileIconPanelScrollBox.Create( AOwner : TComponent );
  2406. begin
  2407.   inherited Create( AOwner );
  2408.   TheFWB := TFileWorkBench.Create( Self );
  2409. end;
  2410.  
  2411. { This function returns the next selected file's name }
  2412. function TFileIconPanelScrollBox.GetNextSelection( SourceDirectory : String;
  2413.                            var CurrentItem : Integer ) : String;
  2414. var TheResult    : String;      { Holds result of function }
  2415.     TheComponent : TComponent;  { Used for typecast        }
  2416.     finished     : boolean;     { Loop control variable    }
  2417.     TheComponentCount : Integer;
  2418. begin
  2419.   TheComponentCount := ComponentCount;
  2420.   { If past end of components exit with no result }
  2421.   if CurrentItem > TheComponentCount then TheResult := '' else
  2422.   begin
  2423.     { Set loop counter and run till find match or run out }
  2424.     finished := false;
  2425.     while not finished do
  2426.     begin
  2427.       { Pull component out of the list and check it }
  2428.       TheComponent := Components[ CurrentItem - 1 ];
  2429.       { Increment counter for later }
  2430.       CurrentItem := CurrentItem + 1;
  2431.       { Do the typecast with AS }
  2432.       if TheComponent is TFileIconPanel then
  2433.       with TheComponent as TFileIconPanel do
  2434.       begin
  2435.         { If its selected make sure OK }
  2436.         if Selected then
  2437.         begin
  2438.           { Don't accept backup for this level of operation }
  2439.           if FTheLabel.Caption <> '..' then
  2440.           begin
  2441.             { Otherwise return the name and abort the loop }
  2442.             TheResult := FTheName;
  2443.             finished := true;
  2444.           end;
  2445.         end
  2446.         else
  2447.         begin
  2448.           { Check to see if out of components }
  2449.           if CurrentItem > TheComponentCount then
  2450.           begin
  2451.             { If so signal error and abort }
  2452.             TheResult := '';
  2453.             finished := true;
  2454.           end;
  2455.         end;
  2456.       end;
  2457.     end;
  2458.   end;
  2459.   GetNextSelection := TheResult;
  2460. end;
  2461.  
  2462. { This procedure places a selection of files in the display based on wildcards }
  2463. procedure TFileIconPanelScrollBox.DisplayRecursiveSearchResults(
  2464.            TheStartingDirectory : String );
  2465. var XCounter ,
  2466.     YCounter   : Integer;
  2467.  
  2468. { This procedure does a recursive file search by first getting all matches (in-}
  2469. { cluding directories) and adding them to the list. Then it checks for ALL the }
  2470. { subdirectories and does the same trick on them til there are no more matches }
  2471. { and no more subdirectories, at which point it exits and recurses back up.    }
  2472. procedure RecursiveFileSearch( TheWorkingDirectory : String; var XCounter ,
  2473.                                YCounter : Integer );
  2474.  
  2475. { VITAL!!! These variables MUST be local for recursrion to work! }
  2476. var
  2477.     Finished        : Boolean;         { Loop flag              }
  2478.     TheSR           : TSearchRec;      { Searchrecord for FF/FN }
  2479.     TheResult       : Integer;         { return variable        }
  2480.     TargetPath ,
  2481.     FileMask   ,
  2482.     TheStoredWorkingDirectory ,
  2483.     ModifiedDirectory  : String;       { path for FF/FN         }
  2484.     TheFIP          : TFileIconPanel;  { generic FIP holder     }
  2485.     ButtonColor   ,                    { main panel color       }
  2486.     ButtonHLColor ,                    { bright panel color     }
  2487.     ButtonSColor  ,                    { dark panel color       }
  2488.     Textcolor       : TColor;          { label text color       }
  2489.  
  2490. begin
  2491.   { Set up the initial variables }
  2492.   Finished := false;
  2493.   TheStoredWorkingDirectory := TheWorkingDirectory;
  2494.   Targetpath := ExtractFilePath( TheWorkingDirectory );
  2495.   FileMask := ExtractFileName( TheWorkingDirectory );
  2496.   { Make the call to FindFirst set to get any file }
  2497.   TheResult := FindFirst( TheWorkingDirectory , faAnyFile , TheSR );
  2498.   if TheResult < 0 then finished := true;
  2499.   if (( TheSr.Name <> '.' ) and ( TheSr.Name <> '..' ) and ( TheResult >= 0 ))
  2500.   then begin
  2501.     if (( FileGetAttr( TargetPath + TheSR.Name ) and faDirectory ) =
  2502.      faDirectory ) then
  2503.     begin { A directory }
  2504.       GetColorsForFileIcon( TargetPath + TheSR.Name , ButtonColor ,
  2505.        ButtonHLColor , ButtonSColor , TextColor );
  2506.       { If found create a new FileIconPanel on the imported scrollbox }
  2507.       { Note sending 0 ExtraData parameter to indicate file not drive }
  2508.       TheFIP := TFileIconPanel.Create( Self );
  2509.       TheFIP.Parent := Self;
  2510.       TheFIP.Initialize((( XCounter - 1 ) * TheIconSpacing ),
  2511.        (( YCounter - 1  ) * TheIconSpacing ) , TheIconSize , TheIconSize , 3 ,
  2512.         7 , ButtonColor, ButtonHLColor , ButtonSColor , TextColor , TargetPath
  2513.          + TheSr.Name , 'MS Serif' , [] , 0 );
  2514.       { Increment column counter and move to new row if past limit }
  2515.       XCounter := XCounter + 1;
  2516.       if XCounter > MaxIconsInARow then
  2517.       begin
  2518.         XCounter := 1;
  2519.         YCounter := YCounter + 1;
  2520.       end;
  2521.     end
  2522.     else
  2523.     begin { A File }
  2524.       { Set up the default color scheme for files }
  2525.       GetColorsForFileIcon( TargetPath + TheSR.Name , ButtonColor ,
  2526.        ButtonHLColor , ButtonSColor , TextColor );
  2527.       { If found create a new FileIconPanel on the imported scrollbox }
  2528.       { Note sending 0 ExtraData parameter to indicate file not drive }
  2529.       TheFIP := TFileIconPanel.Create( Self );
  2530.       TheFIP.Parent := Self;
  2531.       TheFIP.Initialize((( XCounter - 1 ) * TheIconSpacing ),
  2532.        (( YCounter - 1  ) * TheIconSpacing ) , TheIconSize, TheIconSize , 3 ,
  2533.         7 , ButtonColor, ButtonHLColor , ButtonSColor , TextColor , TargetPath
  2534.          + TheSr.Name , 'MS Serif' , [] , 0 );
  2535.       { Increment column counter and move to new row if past limit }
  2536.       XCounter := XCounter + 1;
  2537.       if XCounter > MaxIconsInARow then
  2538.       begin
  2539.         XCounter := 1;
  2540.         YCounter := YCounter + 1;
  2541.       end;
  2542.     end;
  2543.   end;
  2544.   { loop through all files in the directory and look for matches }
  2545.   while not Finished do
  2546.   begin
  2547.     { Make call to FindNext, using only SearchRecord from FindFirst }
  2548.     TheResult := FindNext( TheSR );
  2549.     { A -1 result means no more files so exit }
  2550.     if TheResult <> 0 then finished := true else
  2551.     begin
  2552.       if (( FileGetAttr( TargetPath + TheSR.Name ) and faDirectory ) =
  2553.        faDirectory ) then
  2554.       begin { A directory }
  2555.         { Set up the blue color scheme for directories }
  2556.         GetColorsForFileIcon( TargetPath + TheSR.Name , ButtonColor ,
  2557.          ButtonHLColor , ButtonSColor , TextColor );
  2558.         { If found create a new FileIconPanel on the imported scrollbox }
  2559.         { Note sending 0 ExtraData parameter to indicate file not drive }
  2560.         TheFIP := TFileIconPanel.Create( Self );
  2561.         TheFIP.Parent := Self;
  2562.         TheFIP.Initialize((( XCounter - 1 ) * TheIconSpacing ),
  2563.          (( YCounter - 1  ) * TheIconSpacing ) , TheIconSize , TheIconSize , 3 ,
  2564.            7 , ButtonColor, ButtonHLColor , ButtonSColor , TextColor ,
  2565.             TargetPath + TheSr.Name , 'MS Serif' , [] , 0 );
  2566.         { Increment column counter and move to new row if past limit }
  2567.         XCounter := XCounter + 1;
  2568.         if XCounter > MaxIconsInARow then
  2569.         begin
  2570.           XCounter := 1;
  2571.           YCounter := YCounter + 1;
  2572.         end;
  2573.       end
  2574.       else
  2575.       begin { A File }
  2576.         { Set up the default color scheme for files }
  2577.         GetColorsForFileIcon( TargetPath + TheSR.Name , ButtonColor ,
  2578.          ButtonHLColor , ButtonSColor , TextColor );
  2579.         { If found create a new FileIconPanel on the imported scrollbox }
  2580.         { Note sending 0 ExtraData parameter to indicate file not drive }
  2581.         TheFIP := TFileIconPanel.Create( Self );
  2582.         TheFIP.Parent := Self;
  2583.         TheFIP.Initialize((( XCounter - 1 ) * TheIconSpacing ),
  2584.          (( YCounter - 1  ) * TheIconSpacing ) , TheIconSize , TheIconSize , 3 ,
  2585.           7 , ButtonColor, ButtonHLColor , ButtonSColor , TextColor ,
  2586.            TargetPath + TheSr.Name , 'MS Serif' , [] , 0 );
  2587.         { Increment column counter and move to new row if past limit }
  2588.         XCounter := XCounter + 1;
  2589.         if XCounter > MaxIconsInARow then
  2590.         begin
  2591.           XCounter := 1;
  2592.           YCounter := YCounter + 1;
  2593.         end;
  2594.       end;
  2595.     end;
  2596.   end;
  2597.   { Set up the variables to do recursive calls on all directories}
  2598.   Finished := false;
  2599.   ModifiedDirectory := ExtractFilePath( TheWorkingdirectory ) + '*.*';
  2600.   { Make the call to FindFirst set to get any file, ignore result }
  2601.   TheResult := FindFirst( ModifiedDirectory , faDirectory , TheSR );
  2602.   while not Finished do
  2603.   begin
  2604.     { Make call to FindNext, using only SearchRecord from FindFirst }
  2605.     TheResult := FindNext( TheSR );
  2606.     { A -1 result means no more files so exit }
  2607.     if TheResult <> 0 then finished := true
  2608.     else
  2609.     begin
  2610.       if TheSR.Name <> '..' then { Ignore backup in this case }
  2611.       begin
  2612.         { Do second check due to bug in FindNext }
  2613.         if (( FileGetAttr( TargetPath + TheSR.Name ) and faDirectory )
  2614.         = faDirectory ) then
  2615.         begin
  2616.           { Set up modified directory to recurse into }
  2617.           ModifiedDirectory := ExtractFilePath( TheStoredWorkingDirectory ) +
  2618.            TheSR.Name + '\' + FileMask;
  2619.           { Perform the recursion }
  2620.           RecursiveFileSearch( ModifiedDirectory , XCounter , YCounter );
  2621.         end;
  2622.       end;
  2623.     end;
  2624.   end;
  2625. end;
  2626.  
  2627. begin
  2628.   { Keep the scrollbox from updating during refresh }
  2629.   Visible := false;
  2630.   { Make the clear call }
  2631.   ClearTheFIPs;
  2632.   XCounter := 1;
  2633.   YCounter := 1;
  2634.   { Get the drives for the current machine }
  2635.   AddDriveIcons( XCounter , YCounter );
  2636.   RecursiveFileSearch( TheStartingDirectory , XCounter , YCounter );
  2637.   { Make the scrollbox visible again }
  2638.   Visible := true;
  2639. end;
  2640.  
  2641. end.
  2642.